1 回答
TA贡献1794条经验 获得超8个赞
如果小提琴不知何故不再工作,下面是 SQL 代码。(假设MySQL/MariaDB)
create table product
(
id int auto_increment,
name varchar(255) not null,
constraint product_pk
primary key (id)
);
create table shop
(
id int auto_increment,
name varchar(255) not null,
constraint shop_pk
primary key (id)
);
create table product_shop
(
id int auto_increment,
product_id int,
shop_id int,
quantity int not null default 0,
constraint product_shop_pk
primary key (id)
);
alter table product_shop
add constraint product_shop_product_fk
foreign key (product_id) references product (id);
alter table product_shop
add constraint product_shop_shop_fk
foreign key (shop_id) references shop (id);
- 1 回答
- 0 关注
- 93 浏览
添加回答
举报