数据库系统基础教程第六章答案
【篇一:数据库系统基础教程答案ch7】
>数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案
数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 数据库系统基础教程答案 7.1.1 a)
create table movies ( titlechar(100), yearint,
length int,
gee char(10),
studioname char(30), producerc# int,
primary key (title, year),
foreign key (producerc#) references movieexec(cert#) ); or
create table movies ( titlechar(100), yearint,
length int,
gee char(10),
studioname char(30),
producerc# int references movieexec(cert#), primary key (title, year) ); b)
create table movies ( titlechar(100), yearint,
length int,
gee char(10),
studioname char(30),
producerc# int references movieexec(cert#) on delete set null on update set null,
primary key (title, year) );
c)
create table movies ( titlechar(100), yearint,
length int,
gee char(10),
studioname char(30),
producerc# int references movieexec(cert#) on delete cascade on update cascade,
primary key (title, year) ); d)
create table starsin (
movietitle char(100)references movie(title), movieyear int,
starname char(30),
primary key (movietitle, movieyear, starname) ); e)
create table starsin (
movietitle char(100)references movie(title) on delete cascade, movieyear int,
starname char(30),
primary key (movietitle, movieyear, starname) );
7.1.2
to declare such a foreign-key constraint between the relations movie and starsin, values of the referencing attributes in movie should appear in moviestar as unique values. however, based on primary key declaration in relation starin, the uniqueness of movies is guaranteed with movietitle, movieyear, and starname attributes. even with title and year as referencing attributes there is no way of referencing unique movie from starsin
without starname information. therefore, such a constraint can not be expressed using a foreign-key constraint. 7.1.3
alter table product
add primary key (model);
alter table pc
add foreign key (model) references product (model); alter table laptop
add foreign key (model) references product(model); alter table printer
add foreign key (model) references product (model); 7.1.4
alter table classes
add primary key (class); alter table ships
add primary key (name); alter table ships
add foreign key (class) references classes (calss); alter table battles
add primary key (name); alter table outcomes
add foreign key (ship) references ships (name); alter table outcomes
add foreign key (battle) references battles (name); 7.1.5 a)
alter table ships
add foreign key (class) references classes (class) on delete set null on update set null;
in addition to the above declaration, class must be declared the primary key for classes. b)
alter table outcome
add foreign key (battle) references battles (name) on delete set null on update set null; c)
alter table outcomes
add foreign key (ship) references ships (name) on delete set null on update set null; 7.2.1 a)
yearint check (year = 1915)
b)
length int check (length = 60 and length = 250) c)
studioname char(30)
check (studioname in (?disney?, fox?, ?mgm?, ?paramount?) ) 7.2.2 a)
create table laptop ( …
speed decimal(4,2) check (speed = 2.0) … ); b)
create table printer ( …
type varchar(10)
check (type in (?laser?, ?ink-jet?, ?bubble-jet?)) … ); c)
create table product ( …
type varchar(10)
check (type in(?pc?, ?laptop?, ?printer?)) … ); d)
create table product ( …
model char(4)
check (model in (select model from pc union all
select model from laptop union all
select model from printer)) … );
* note this doesn?t check the attribute constraint violation caused by deletions from pc, laptop, or printer 7.2.3
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库数据库系统基础教程第六章答案在线全文阅读。
相关推荐: