Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE items (
- id integer AUTO_INCREMENT,
- name varchar(255) NOT NULL,
- price int unsigned NOT NULL,
- PRIMARY KEY (id)
- )
- CREATE TABLE companies (
- id integer AUTO_INCREMENT,
- name varchar(255) NOT NULL,
- address varchar(255) NOT NULL,
- PRIMARY KEY (id)
- )
- CREATE TABLE orders (
- id integer AUTO_INCREMENT,
- date date NOT NULL,
- company_id integer NOT NULL,
- PRIMARY KEY (id),
- INDEX (company_id),
- FOREIGN KEY(company_id)
- REFERENCES companies(id)
- )
- CREATE TABLE order_details (
- order_id integer NOT NULL,
- item_id integer NOT NULL,
- number integer unsigned NOT NULL,
- PRIMARY KEY (order_id, item_id),
- FOREIGN KEY(order_id)
- REFERENCES orders(id)
- ON DELETE CASCADE,
- FOREIGN KEY(item_id)
- REFERENCES items(id)
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement