数据库系统基础教程答案ch4 下载本文

内容发布更新时间 : 2024/5/20 22:02:19星期一 下面是文章的全部内容请认真阅读。

4.8.1

Customers(SSNo,name,addr,phone) Flights(number,day,aircraft)

Bookings(row,seat,custSSNo,FlightNumber,FlightDay)

Customers(\Flights(\

Bookings(row,seat,\

4.8.2 a)

Movies(title,year,length,genre) Studios(name,address)

Presidents(cert#,name,address)

Owns(movieTitle,movieYear,studioName) Runs(studioName,presCert#)

Movies(\Studios(\

Presidents(\

Owns(\Runs(\ b)

Since the subclasses are disjoint, Object Oriented Approach is used. The hierarchy is not complete. Hence four relations are required Movies(title,year,length,genre)

MurderMysteries(title,year,length,genre,weapon) Cartoons(title,year,length,genre)

Cartoon-MurderMysteries(title,year,length,genre,weapon)

Movies(\

MurderMysteries(\Cartoons(\

Cartoon-MurderMysteries(\ c)

Customers(ssNo,name,phone,address) Accounts(number,balance,type) Owns(custSSNo,accountNumber)

Customers(\Accounts(\Owns(\

d)

Teams(name,captainName) Players(name,teamName) Fans(name,favoriteColor) Colors(colorname)

For Displays association,

TeamColors(teamName,colorname) RootsFor(fanName,teamName) Admires(fanName,playerName)

Teams(\Players(\Fans(\Colors(\

For Displays association,

TeamColors(\RootsFor(\Admires(\ e)

People(ssNo,name,fatherSSNo,motherSSNo)

People(\ f)

Students(email,name)

Courses(no,section,semester,professorEmail) Departments(name)

Professors(email,name,worksDeptName)

Takes(letterGrade,studentEmail,courseNo,courseSection,courseSemester)

Students(\

Courses(\Departments(\

Professors(\

Takes(letterGrade,\

4.8.3 a)

Each and every object is a member of exactly one subclass at leaf level. We have nine classes at the leaf of hierarchy. Hence we need nine relations. b)

All objects only belong to one subclass and its ancestors. Hence, we need not consider every possible subtree but rather the total number of nodes in tree. Hence we need thirteen relations. c)

We need all possible subtrees. Hence 218 relations are required.

4.9.1

class Customer (key (ssNo)){ attribute integer ssNo; attribute string name; attribute string addr; attribute string phone; relationship Set ownsAccts inverse Account::ownedBy; };

class Account (key (number)){ attribute integer number; attribute string type; attribute real balance; relationship Set ownedBy inverse Customer::ownsAccts; };

4.9.2 a)

Modify class Account to contain relationship Customer ownedBy (no Set) b)

Also remove set in relationship ownsAccts of class Customer. c)

ODL allows a collection of primitive types as well as structures. To class

Customer add following attributes in place of simple attributes addr and phone: Set

Set d)

ODL allows structures and collections recursively.

Set>

4.9.3

Collections are allowed in ODL. Hence, Colors Set can become an attribute of Teams.

class Colors(key(colorname)){

attribute string colorname; relationship Set FavoredBy inverse Fans::Favors; relationship set DisplayedBy inverse Teams::Displays; };

class Teams(key(name)){

attribute string name; relationship set Displays inverse Colors::DisplayedBy; relationship set PlayedBy inverse Players::Plays; relationship PLayers CaptainedBy inverse Platyers::Captains; relationship set RootedBy inverse Fans::Roots; };

class Players(key(name)){ attribute string name; relationship Set Plays inverse Teams::PlayedBy; relationship Teams Captains inverse Teams::CaptainedBy; relationship Set AdmiredBy inverse Fans::Admires; };

class Fans(key(name)){ attribute string name; relationship Colors Favors inverse Colors::FavoredBy; relationship Set RootedBy inverse Teams::Roots; relationship Set Admires inverse Players::AdmiredBy; };

4.9.4

class Person { attribute string name; relationship Person motherOf inverse Person::childrenOfFemale; relationship Person fatherOf inverse Person::childrenOfMale; relationship Set children inverse Person::parentsOf; relationship Set childrenOfFemale inverse Person::motherOf; relationship Set childrenOfMale inverse Person::fatherOf; relationship Set parentsOf inverse Person::children; };

4.9.5

The struct education{string degree,string school,string date} cannot have duplication.

Hence use of Sets does not make any different as compared to bags, lists, or arrays.

Lists will allow faster access/queries due to the already sorted nature.

4.9.6 a)

class Departments(key (name)) { attribute string name;

relationship Courses offers inverse Courses::offeredBy; };

class Courses(key (number,offeredBy)) { attribute string number;

relationship Departments offeredBy inverse Departments::offers; }; b)

class Leagues (key (name)) { attribute name;

relationship Teams contains inverse Teams::belongs; };

class Teams(key (name,belongs)) { attribute name,

relationship Leagues belongs inverse Leagues::contains; relationship Players play inverse Players::plays; };

class Players (key(number,plays)) { attribute number,

relationship Teams plays inverse Teams::play; };