下面两个关系模式:
职工(职工号,姓名,年龄,职务,工资,部门号),职工号为主键
部门(部门号,名称,经理名,电话),其中部门号为主码
(1)定义每个模式的主键
(2)定义参照完整性
(3)定义职工年龄不得超过60岁
create table dept
(
Deptno number(2) primary key,
Deptname varchar(10),
Manager varchar(10),
PhoneNuber char(12)
);
create table emp
(
Empno number(4) primary key,
Ename varchar(10),
Age number(2),
Job varchar(9),
Sal number(7, 2),
Deptno number(2),
constraint C1 check(Age <= 60),
constraint FK_DEPTNO foreign key(Deptno)
references DEPT(Deptno)
);
关系Male记录注册的男宾信息,关系Female记录注册的女宾信息,建立一个断言,将来宾人数限制在50以内
create table male(
Snumber smallint primary key,
name char(8),
age smallint
);
crate table female(
Snumber smallint primary key,
Name char(8),
Age smallint
);
create assertion Party
check((select count(*) from male)+(select count(*) from female) <= 50);