56,678
社区成员
发帖
与我相关
我的任务
分享
create table ProductType (
id int primary key,
title varchar(200),
description varchar(2000) not null,
size int not null
);
create table Product (
id int primary key,
started date not null,
completed date,
label varchar(200),
type int not null,
foreign key(type) references ProductType(id) on update cascade on delete no action
);
create table Factory (
id int primary key,
address varchar(200) not null unique
);
create table Machine (
id int primary key,
code varchar(200) not null,
partOf int,
foreign key(partOf) references Factory(id) on update cascade on delete no action,
unique(code, partOf)
);
create table Employee (
id int primary key,
name varchar(200) not null
);
create table Qualification (
canRepair int,
foreign key(canRepair) references ProductType(id) on update cascade on delete cascade,
canBeRepairedBy int,
foreign key(canBeRepairedBy) references Employee(id) on update cascade on delete cascade,
primary key(canRepair, canBeRepairedBy),
level enum('Novice', 'Intermediate', 'Expert') -- Enumeration strategy: fixed enumeration
);
create table ProductProcessor ( -- Implementation of the Product-Machine association
processes int primary key,
foreign key(processes) references Product(id) on update cascade on delete cascade,
processedBy int not null unique,
foreign key(processedBy) references Machine(id) on update cascade on delete cascade
);