Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use studydb;
- CREATE TABLE buyer
- (
- buyer_id int not null key auto_increment,
- buyer_name varchar(20) not null
- );
- CREATE TABLE product
- (
- product_id int not null primary key auto_increment,
- product_name varchar(20) not null
- );
- CREATE TABLE orders
- (
- order_id int not null primary key auto_increment,
- buyer_id int not null,
- product_id int not null,
- qty int not null
- );
- alter table orders
- add foreign key (buyer_id)
- references buyer (buyer_id);
- alter table orders
- add foreign key (product_id)
- references product (product_id);
- insert into buyer values (1,'ABC Trade');
- insert into buyer values (2,'DEF Logistics');
- insert into product values (1,'Watermelon');
- insert into product values (2,'Cabbage');
- insert into product values (3,'Banana');
- insert into orders values (1,1,1,10);
- insert into orders values (2,1,2,100);
- insert into orders values (3,2,1,20);
- insert into orders values (4,2,2,200);
- select * from buyer;
- drop table orders;
- drop table buyer;
- drop table product;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement