数据库系统基础教程第四章答案 下载本文

内容发布更新时间 : 2024/11/15 3:42:40星期一 下面是文章的全部内容请认真阅读。

(c) Courses and LabCourses are combined into one relation.

Depts(name, chair)

Courses(number, deptName, room, allocation)

4.6.2 (a)

Person(name,address)

ChildOf(personName,personAddress,childName,childAddress)

Child(name,address,fatherName,fatherAddress,motherName,motherAddresss) Father(name,address,wifeName,wifeAddresss) Mother(name,address)

Since FatherOf and MotherOf are many-one relationships from Child, there is no need for a separate relation for them. Similarly the one-one relationship Married can be included in Father (or Mother). ChildOf is a many-many relationship and needs a separate relation.

However the ChildOf relation is not required since the relationship can be

deduced from FatherOf and MotherOf relationships contained in Child relation. (b)

A person cannot be both Mother and Father. Person(name,address)

PersonChild(name,address)

PersonChildFather(name,address) PersonChildMother(name,address) PersonFather(name,address) PersonMother(name,address)

ChildOf(personName,personAddress,childName,childAddress) FatherOf(childName,childAddress,fatherName,fatherAddress) MotherOf(childName,childAddress,motherName,motherAddress) Married(husbandName,husbandAddress,wifeName,wifeAddress)

The many-many ChildOf relationship again requires a relation.

An entity belongs to one and only one class when using object-oriented approach. Hence, the many-one relations MotherOf and FatherOf could be added as attributes to PersonChild,PersonChildFather, and PersonChildMother relations.

Similarly the Married relation can be added as attributes to PersonChildMother and PersonMother (or the corresponding father relations).

(c) For the Person relation at least one of husband and wife attributes will be null.

Person(personName,personAddress,fatherName,fatherAddress,motherName,motherAddresss,wifeName,wifeAddresss,husbandName,husbandAddress)

ChildOf(personName,personAddress,childName,childAddress)

4.6.3 (a)

People(name,fatherName,motherName) Males(name) Females(name) Fathers(name) Mothers(name)

ChildOf(personName,childName) (b)

People(name)

PeopleMale(name)

PeopleMaleFathers(name) PeopleFemale(name)

PeopleFemaleMothers(name)

ChildOf(personName,childName) FatherOf(childName,fatherName) MotherOf(childName,motherName)

People cannot belong to both male and female branch of the ER diagram.

Moreover since an entity belongs to one and only one class when using object-oriented approach, no entity belongs to People relation.

Again we could replace MotherOf and FatherOf relations by adding as attributes to PeopleMale,PeopleMaleFathers,PeopleFemale, and PeopleFemaleMothers relations. (c)

People(name,fatherName,motherName) ChildOf(personName,childName)

4.6.4 (a)

Each entity set results in one relation. Thus both the minimum and maximum number of relations is e.

The root relation has a attributes including k keys. Thus the minimum number of attributes is a. All other relations include the k keys from root along with their a attributes. Thus the maximum number of attributes is a+k.

(b)

The relation for root will have a attributes. The relation representing the whole tree will have e*a attributes.

The number of relations will depend on the shape of the tree. A tree of e

entities where only one child exists(say left child only) would have the minimum number of relations. Thus below figure will only contain 4 subtrees that contain root E1,E1E2,E1E2E3, and E1E2E3E4. With e entity sets, minimum e relations are possible.

The maximum number of subtrees result when all the entities(except root) are at depth 1. Thus below figure will contain 8 subtrees that contain root

E1,E1E2,E1E3,E1E4,E1E2E3,E1E3E4,E1E2E4,and E1E2E3E4. With e entity sets, maximum 2^(e-1) relations are possible.

(c)

The nulls method always results in one relation and contains attributes from all e entities i.e. e*a attributes.

Summarizing for a,b, and c above;

#Components #Relations Min Max Min Max Method

straight-E/R a a e e

object-oriented a e*a e 2^(e-1) nulls e*a e*a 1 1

4.7.1

4.7.2 a)

b)