lec6

17
Exam Revision Lecture 6 IELM 230 Fall 2008

Transcript of lec6

Exam Revision

Lecture 6IELM 230 Fall 2008

13-Oct-08HKUST IELM 230 Fall 2008 Slide 2

Motown Records• Notown Records has decided to store information about musicians who perform on its albums

(as well as other company data) in a database. The company has wisely chosen to hire you as a database designer (at your usual consulting fee of USD2500/day).

• Each musician that records at Notown has an SSN, a name, all address, and a phone number. Poorly paid musicians often share the same address, and no address has more than one phone.

• Each instrument used in songs recorded at Notown has a name (e.g., guitar, synthesizer, flute) and a musical key (e.g., C, B-fiat, E-flat).

• Each album recorded on the Notown label has a title, a copyright date, a format (e.g., CD or MC), and an album identifier.

• Each song recorded at Notown has a title and an author.• Each musician may play several instruments, and a given instrument may be playcd by several

musicians.• Each album has a number of songs on it, but no song may appear on more than one album.• Each song is performed by one or more musicians, and a musician may perform a number of

songs.• Each album has exactly one musician who acts as its producer. A musician may produce

several albums, of course.• Design a conceptual schema for Notown and draw an ER diagram for your schema. The

preceding information describes the situation that the Notown database must model. Be sure to indicate all key and cardinality constraints and any assumptions you make. Identify any constraints you are unable to capture in the ER diagram and briefly explain why you could not express them.

13-Oct-08HKUST IELM 230 Fall 2008 Slide 3

Q3

13-Oct-08HKUST IELM 230 Fall 2008 Slide 4

Q3

13-Oct-08HKUST IELM 230 Fall 2008 Slide 5

Mid Term Exam

• Next Week: – LTD Oct 20 : 1600-1800 hrs– 2 A4-Crypt sheet– About Four Questions– Covers topics from all previous lectures– Similar to the sample mid-term, but a little harder– It is likely that there will be a mini case study in the

mid-term

13-Oct-08HKUST IELM 230 Fall 2008 Slide 6

Question 1

13-Oct-08HKUST IELM 230 Fall 2008 Slide 7

Answer

Departments (dno, dname, budget, Manager)Foreign Key: Manager references Employees(ssn)

Employees (ssn, salary, phone)Works_In (ssn, dno)

Foreign Key: ssn references Employeesdno references Departments

Child (name, ssn, age)Foreign Key: ssn references Employees

13-Oct-08HKUST IELM 230 Fall 2008 Slide 8

Question 2Draw an appropriate ER-Diagram for the following scenario, Publishers publish many different types of professional journals

and books. Some publishers only publish books, some journals, and some both. No book or journal is published by more than one publisher. An author may write either books, journal articles, or both. A journal typically contains several articles, each one written by one or more authors. No article appears in more than one journal. Any journal may have one or more abbreviations, or none.

Every book and article is reviewed by several professionals in the field who may or may not be authors as well. Of course, an author never reviews his or her own book or article. Each book reviewer and author works for and is paid by a single publisher.Article authors and reviewers are not paid, however, and thus article reviewers are never book reviewers. Authors and reviewers who are not paid by a publisher are known as independent professionals.

13-Oct-08HKUST IELM 230 Fall 2008 Slide 9

Answer

13-Oct-08HKUST IELM 230 Fall 2008 Slide 10

Question 3Suppose we have a relation in which we want to record for each

person their name, Social Security number, and birthdate. Also for each child of the person, the name, Social Security number, and birthdate of the child, and for each automobile the person owns, its serial number and make. To be more precise, this relation has all the tuples (n, s, b, cn, cs, cb, as, am) such that– n is that name of the person with Social Security number s– b is n’s birthdate– cn is the name of one of n’s children– cs is cn’s social security number– cb is cn’s birthdate– as is the serial number of one of n’s automobiles– am is the make of the automobile with serial number as

• [10 marks] Write down the functional dependencies we would expect to hold

• [15 marks] Suggest a decomposition of the relation into 3NF

13-Oct-08HKUST IELM 230 Fall 2008 Slide 11

Answer

Write down the functional dependencies we would expect to hold

s -> n, s-> b, cs -> cn, cs -> cb, (cn,n)->cs, (s, as)->m (the license number and the owner will

determine what type of car)

Suggest a decomposition of the relation into 3NF

Person: s, n, bChild: s, cs, cn, cbAutomobile: s, as, am

13-Oct-08HKUST IELM 230 Fall 2008 Slide 12

Question 4

Give a simple definition of a data model. Explain the connection between real-world information and the data model.

Solution: A data model provides a method and a means for describing real-world information requirements in a form that can be designed and implemented as a computer database system. The method abstracts the characteristics of real-world information.

13-Oct-08HKUST IELM 230 Fall 2008 Slide 13

Question 4

What are the two techniques for creating a generic or semantic data model?

Solution: Object Based Model, ER-Model

13-Oct-08HKUST IELM 230 Fall 2008 Slide 14

Question 4

What are data views? What are the two methods for data view integration?

Solution: Data views are the views of the database by different user groups, part of information requirements. Two methods: to merge individual user views and to integrate partial data models

13-Oct-08HKUST IELM 230 Fall 2008 Slide 15

Question 4

Explain the difference between a weak and a strong entity set.

Solution: A weak entity type depends on another regular entity type for its existence. Weak entities depend on the corresponding strong entities for identification.

13-Oct-08HKUST IELM 230 Fall 2008 Slide 16

Question 4

We can convert any weak entity set to a strong entity set by simply adding appropriate attributes. Why, then, do we have weak entity sets?

Solution: We can convert any weak entity set to a strong entity set by adding the key of the corresponding strong entity to the weak entity.

Better representation.

13-Oct-08HKUST IELM 230 Fall 2008 Slide 17

Question 4

Consider an E-R diagram in which the same entity set appears several times. Why is allowing this redundancy a bad practice that one should avoid whenever possible?

Solution: Redundancy is usually not a good practice unless under some special circumstances. In this case, it can result in update anomaly and it wastes space.