Cấu trúc bảng+
CREATE TABLE customers (
id integer PRIMARY KEY,
name text NOT NULL,
email text,
city text NOT NULL,
signup_date date NOT NULL,
segment text NOT NULL
);
CREATE TABLE products (
id integer PRIMARY KEY,
name text NOT NULL,
category text NOT NULL,
price numeric(12, 2) NOT NULL,
stock integer NOT NULL
);
CREATE TABLE orders (
id integer PRIMARY KEY,
customer_id integer NOT NULL REFERENCES customers(id),
order_date date NOT NULL,
status text NOT NULL
);
CREATE TABLE order_items (
id integer PRIMARY KEY,
order_id integer NOT NULL REFERENCES orders(id),
product_id integer NOT NULL REFERENCES products(id),
quantity integer NOT NULL,
unit_price numeric(12, 2) NOT NULL
);