Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE clients
- (
- id BIGINT AUTO_INCREMENT
- PRIMARY KEY,
- first_name VARCHAR(32) NOT NULL,
- last_name VARCHAR(32) NOT NULL
- );
- CREATE TABLE items
- (
- id BIGINT AUTO_INCREMENT
- PRIMARY KEY,
- name VARCHAR(32) NOT NULL,
- price_currency VARCHAR(3) NOT NULL,
- price_amount DECIMAL(7,2) NOT NULL
- );
- CREATE TABLE orders
- (
- id BIGINT AUTO_INCREMENT
- PRIMARY KEY,
- address_building VARCHAR(32) NOT NULL,
- address_city VARCHAR(32) NOT NULL,
- address_street VARCHAR(32) NOT NULL,
- created datetime(6) NOT NULL,
- express INT NOT NULL,
- STATUS VARCHAR(1) NOT NULL,
- client_id BIGINT NOT NULL,
- CONSTRAINT orders2client_fk
- FOREIGN KEY (client_id) REFERENCES clients (id)
- );
- CREATE TABLE order_items
- (
- order_id BIGINT NOT NULL,
- quantity INT NOT NULL,
- item_id BIGINT NOT NULL,
- PRIMARY KEY (order_id, item_id),
- CONSTRAINT order_items2item_fk
- FOREIGN KEY (item_id) REFERENCES items (id),
- CONSTRAINT order_items2order_fk
- FOREIGN KEY (order_id) REFERENCES orders (id)
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement