Download Exam 1 key

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

SQL wikipedia , lookup

Microsoft Access wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Serializability wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Oracle Database wikipedia , lookup

IMDb wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Ingres (database) wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Concurrency control wikipedia , lookup

Database wikipedia , lookup

Versant Object Database wikipedia , lookup

Relational algebra wikipedia , lookup

Clusterpoint wikipedia , lookup

ContactPoint wikipedia , lookup

Database model wikipedia , lookup

Relational model wikipedia , lookup

Transcript
CS 370/IT 376 Fall 2012 Exam 1
Page 1
Database Management Systems
Sept. 28, 2012
Name_______Key______________
1. Match the best of the three schema levels (E=external, P=physical and C=conceptual) in a database
system architecture to each of the characteristics.
[10 pts]
_C__-- An Entity-Relationship model helps visualize this schema level.
_P__-- The layout of the data within the storage file system is defined in this schema level.
_C__-- There is exactly one schema at this level detailing all data attributes, their types and constraints.
_P__-- The schema at this level is typically generated automatically from the conceptual schema.
_E__-- A simplified view of the database is often provided at this level for the end user.
_E__-- Access to some of the database tables or attributes can be limited by this schema level.
_E__-- There can be multiple schemas at this level.
_P__-- The table indexing schemes for improved performance are found at this level.
_P__ and _C_-- The mappings between these levels provide for program-data independence.
2. True/False on database approaches.
[6 pts]
_F___ The relational model was the earliest major database approach.
_T___ The hierarchical model represents the database schema as a tree.
_T___ A relational model database is most closely related to mathematical set theory.
_F___ An object oriented database model is akin to a hierarchical database model.
_T___ A network database approach is the most efficient in use of storage and best in performance.
_F___ An object oriented database is today’s primary database approach.
3. Define each of these terms and give an example to support the definition.
[12 pts]
Database persistence: storage and changes to data in the database are permanent; loss of power does not
result in loss of data
Database administrator: person in charge of managing the database design and structure, oversees access
to the database
Integrity constraint: policies regarding the requirements necessary to keep the data consistent and
accurate
Multivalued attribute: an attribute that can have more than one value; must be recognized as such and
handled as a special case.
CS 370/IT 376 Fall 2012 Exam 1
4.
Page 2
True/false on functional dependency theory.
[10 pts]
__T___ Functional dependency analysis aids in the normalization of a relational schema.
__T___ Multiple entries of a fact is at the root of insertion and deletion anomalies in a relational database.
__F___ Normalization attempts to retain redundant facts stored in a database.
__F___ A null value is the empty string or 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.
__F___ In practical terms, we want other all non-key attributes to functionally determine the primary key in any
relation.
__F____ Functional dependencies are reflexive, i.e., if a →b then b →a
__T___ Transitivity of functional dependencies means that if b →c and a→b then a→c.
__F___ Decomposition of functional dependencies means that if a→bc then a→b and b→c
5. For parts a-c, assume we have a relation with the scheme
TheatreProductions(Title, ShowDateTime, Writer, Director, CopyrightYear, Attendance )
[12 pts]
a.
What would be the likely primary key attribute(s)? ___Title, ShowDateTime________[2]
title may be optional
b. List all non-trivial functional dependencies [7]?
Title > Writer, CopyrightYear,
(Title,) ShowDateTime -> Writer, Director, CopyrightYear, Attendance
Writer, CopyrightYear -> Title
c. If this relation were used as defined (not normalized), describe the insertion and deletion anomalies that
could arise. [3]
Cannot store basic facts about writers, directors, and shows without a show date, time and attendance, of vice
versa
CS 370/IT 376 Fall 2012 Exam 1
Page 3
6. For the following ER diagram develop the relational schema using the pattern TableName(attribute-list).
Underline the key attribute(s) in each relation. 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.
[15 pts]
Customer(CustId, Name, Address, Phone, creditLimit)
Order(OrderNo, CustId Date, Total , ….)
Supplier (SupplierNo, SubName, Phone, SupAddr,….)
Item( ItemNo, ItemName, UnitPrice, QOH, …)
Supplies(SupplierNo, ItemNo, UnitCost)
Contains(OrderNo, CustId, ItemNo, Quantity)
CS 370/IT 376 Fall 2012 Exam 1
Page 4
For the remaining questions, use the following relational schema for a rental company database. Keys are
(mostly) underlined. The attributes should be self-evident. If not, please ask for clarification.
Customers may rent several items at a time and they are all listed under one invoice. Payment is due
upon return of the items. Credit cards are used in lieu of a deposit and the hold is released on return of
the items, but payment can be by check as well.
CUSTOMER(custID, name, address, zip, phone, custType)
CSZ(zip, city, state)
INVOICE(invID, custID, dateOfInv, finalTotalBill, amountDue, creditCardNo)
ITEMSONHAND(typeID, description, quantityOnHand, totalOwned, dailyRentRate)
ITEMDESCR(itemID, typeID, condition, dateBought, purchasePrice)
RENTED(invID, itemID, dateReturned)
PAYMENT(invID, type, CrCardOrCheckNo, amount, date)
[10 pts]
7. a) Underline the appropriate attribute(s) of the primary key for the relation RENTED.
b) Circle attributes that could be virtual in the INVOICE relation.
c) Draw arrows from foreign keys to their corresponding table and attribute
d).What candidate keys are there in the CUSTOMER relation?
____CustId, {name, address,zip}, phone_____________
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 what 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 ‘contractor’ customer type.
name, phone custType=’Contractor’(Customer)
b) List names of customers from zip 16652 who have had invoices of at least $500.
name zip=16652 and FinalTotalBill >= 500(Customer |X| Invoice)
CS 370/IT 376 Fall 2012 Exam 1
Page 5
c) The pig roasters (id=PIGRSTR) bought before 2005 were discovered to contain asbestos. List
names and phone numbers of customers who have rented one of these items.
name, phone dateBought<2005 and itemID = PIGTSTR(Customer |X| Invoice|X| Rented |X|
ItemDesc)
d) List customer names who have not rented anything since Jan 1 2010.
name, (Customer) - namedateOfInvoice>=’Jan-1-2010’ (Customer |X| Invoice)
probably better to project on ids rather than name for set difference
e) List all customer IDs who have made at least two payments for the same invoice.
custId date != date1Payment |X| Payment[invId, type1, CrCardOrCheckNo1, amount, date1]
|X| Invoice