Documente Academic
Documente Profesional
Documente Cultură
2. True/False on database approaches. [6 pts] __T__ The hierarchical model was the earliest major database approach. __ T __ The hierarchical model represents the database schema as a tree. __ F __ A network model database is most closely related to mathematical set theory. __ T __ An object oriented database model is akin to a network database model. __ F __ A relational database approach has been the most efficient in performance from the beginning. ___ F _ An object oriented database is todays primary database approach. 3. Define each of these terms [12 pts] Database integrity: the maintenance of the accuracy of the data at all times. No operation should be permitted that might violate the rules of the real world. Database administrator: The person who oversees the design, organization and security of the database Weak entity: An entity whose existence depends on another entity. Transactions to an account, e.g. Cardinality of a relationship: Considers the roles and number of instances entities that are legal in a relationship. One to many, many to many, for example
Page 2
[10 pts]
__ T ___ Functional dependency analysis is required in the normalization of a relational schema. __ F ___ Multiple entries of a fact is permitted in a normalized relational database. ___ T __ Normalization attempts to eliminate nulls stored in a database. __ F ___ A null value is equivalent to zero. __ T __ A functional dependency is a relationship between an attribute "Y" and a determinant X (1 or more other attributes) such that for a given value of X the value of the attribute Y is uniquely defined. __ F ___ Functional dependencies can be determined by algorithms to analyze the relation. ___ T __ In practical terms, we want other all non-key attributes to functionally dependent only on the primary key in any relation. ___ F __ Functional dependencies are reflexive, i.e., if a b then b a __ F ___ Transitivity of functional dependencies means that if a c and ab then bc. __ F __ Decomposition of functional dependencies means that if abc then ab and bc
5. For parts a-c, assume we have a relation with the scheme Book (Title, Author, Publisher, PubAddress, PubZip, CopyrightYear, ISBN ) //ISBN = International Standard Book Number [12 pts] a. What would be the likely primary key attribute(s)? ________ISBN____________________[2]
ISBN -> {Title, Author, Publisher, PubAddress, PubZip, CopyrightYear } {Title, Author} ->{ Publisher, PubAddress, PubZip, CopyrightYear, ISBN} Publisher -> PubAddress, PubZip
c. If this relation were used as defined (not normalized), describe the insertion and deletion anomalies that could arise. [3]
A publishers address cannot be stored additionally without at least a book A publishers address is replicated and if changed, would have to update many records
Page 3
6. For the following Presidential ER diagram develop the relational schema using the pattern TableName(attribute-list). In the interest of time and space, just list 3 more non-key attributes in your table from the entities, not all attributes are necessary. Only specify the relations the entities Presidents, Election and Party_History. Include only the relationship that fall between these four entities. Underline the key attribute(s) in each relation. [16 pts]
PRESIDENTS (Pres, Spouse, Party, Birthdate, Deathdate ) and ok if State is added ELECTION (Year, Votes, Pres) PARTY_HISTORY (Party, Year) ELECTIONLOSERS (Party, Year, Name )
Page 4
For the remaining questions, use the following relational schema for a music albums database. Keys are (mostly) underlined. The attributes should be self-evident. If not, please ask for clarification. For a given music track, we code the title, its play length in time (minutes:seconds), its genre (pop, metal, jazz, etc.) and a 5 star maximum rating. The musicians, singers and instrumentalists are all listed in on their contribution to the track. A person may have 1 or more listing for a track. For example someone may both sing and play the piano. The album is a collection of tracks. An album is distributed and owned by a company called the label and has a producer and an engineer. PEOPLE (PID, name, address, zip, phone) CSZ (zip, city, state) TRACKS (trID, title, length, genre, rating, albID) //trID is unique across all albums ALBUMS (albID, albumTitle, year, label, prodPID, engPID, length, price) CONTRIBS (trID, PID, role) [10 pts] 7. a) Underline the appropriate attribute(s) of the primary key for the relation CONTRIBS. b) Circle attributes that could be virtual in the ALBUMS relation. c) Draw arrows from foreign keys to their corresponding relation and attribute. d) What candidate keys are there in the PEOPLE relation? ___{name, address} and phone and PID___
8. Give Relational Algebra statements for the following queries on the rental company database schema. Use the R.A. notation below. BE EXPLICIT in the join condition which attributes make the join where necessary. [25 pts]
Syntax reminder for Relational Algebra expressions: SELECT : condition(relation) PROJECT : attribute-list(relation) SET Operations and JOIN: relation1 OP relation2, where OP is , , - , , , and ||condition RENAME: relation[new attribute names] ASSIGN: new-relation(attrs) R.A. expression
a) List all names and phone numbers of people from zip 90210.
name, phone(zip=90210(PEOPLE))
b) List album titles and labels with a list price of more than $18.
albumTitle, label(price>18(ALBUMS))
Page 5
c) List all the musicians and what they played or contributed to on all jazz type tracks.
name, role(genre= jazz(TRACKS |X| trID=trID CONTRIBS |X| PID= PID PEOPLE))
d) Get a list of names of people who produced OR engineered an album, but did not perform on any track. (Hint: set operations are very helpful)
e) List names of musicians who have contributed in at least two different roles on the same tracks with ratings 4 or higher. (Hint: self-join)