Download Exam 1

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

Oracle Database wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

IMDb wikipedia , lookup

Ingres (database) wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Concurrency control wikipedia , lookup

Database wikipedia , lookup

Clusterpoint wikipedia , lookup

Versant Object Database wikipedia , lookup

ContactPoint wikipedia , lookup

Relational algebra wikipedia , lookup

Database model wikipedia , lookup

Relational model wikipedia , lookup

Transcript
CS 370 Spring 2017 Exam 1
Page 1
Database Management Systems
February 20, 2017
Name__________________________
1. Consider the simplified three level database system architecture of external, internal/physical and
conceptual/logical levels. Fill in the blanks, usually, with one of these levels.
[8 pts]
Entity-relationship modeling is at the ____________ level. Conversion of the ER model to the
relational model is found at the ________________ level. Specifying relationships and their cardinality
occurs at the ____________level. How the tables and data records are structured and organized for
storage are defined in the ________________ level. A simplified presentation of tables occurs at the
________________ level. Tables can also be hidden from the _________ level. There is/are many
view(s) found at the ___________ level. There is/are _____ instance(s) of the model(s) at the internal
level. The database system interface between the internal and logical model provides for internal-logical
data- ________________ so that changes to either level has minimal effect on the other.
2. True/False on database approaches.
[6 pts]
_____ The hierarchical model was the earliest major database approach.
_____ The network model represents the database schema as a tree.
_____ A network modeled database is most closely related to mathematical set theory.
_____ An object oriented database model has similarities to a network database model.
_____ The primary appeal of a relational database in early days was its practical efficiency.
_____ The relational database is expected to remain the primary approach in foreseeable future.
3. Give a concrete, real-life example of each of these concepts
[12 pts]
Database transaction:
Cardinality of a relationship:
Weak entity:
CS 370 Spring 2017 Exam 1
4.
Page 2
True/false on functional dependency theory.
[10 pts]
______ A functional dependency X→Y is an extension of the mathematics concept that a value in X
clearly determines the corresponding value in Y.
______ Functional dependencies can be determined sufficiently by looking at a sample relation.
______ Functional dependencies are reflexive, i.e., if a →b then b →a
______ Transitivity of functional dependencies means that if a →b and c→b then a→c.
______ It’s ok to rewrite ab→c as a→c and b→c, and vice versa.
______ Functional dependency analysis is core in the normalization process of a relational schema, but
is irrelevant in the analysis of an entity’s attributes in the ER model.
______ Multi-valued attributes are not permitted in a 1NF relation.
______ First normal form (1NF) still permits nulls to be stored in database tables.
______ A null value is just the empty string in the case of a non-numeric type attribute.
______ In practical terms, we want other all non-key attributes in the relation to be functionally
dependent only on the candidate keys of the relation.
5. For parts a-c, assume we have a relation with the following schema where a student majors in at most one
major which belongs to a department:
Students (DeptID, DeptName ,DeptChair, StuId, StuName, StuAddr, StuCity, StuState, StuZip, Major)
[14 pts]
a.
What would be the likely primary key attribute? _________________________________[2]
b. List all non-trivial functional dependencies [8]?
c. If this relation were used as defined (not normalized), describe an update anomaly that could arise. [4]
CS 370 Spring 2017 Exam 1
Page 3
6. For the following Presidents ER diagram develop the relational schema using the table pattern
TableName(attribute-list). Just list the tables for the entity Admins, the two entities directly related to
Admins, and any tables arising from the connecting relationships or multivalued attributes. Underline the
key attribute(s) in each relation. Be sure to include the foreign key.
[15 pts]
CS 370 Spring 2017 Exam 1
Page 4
For the remaining questions, use the following relational schema for a company database tracking trips and
expenses. Keys are (mostly) underlined. The attributes should be self-evident. If not, please ask for
clarification.
EMPS (SSN, name, address, zip, phone, deptno, jobTitle, salary)
CSZ (zip, city, state)
DEPTS (deptno, deptName, deptMgrSSN)
TRIPS (TripId, DestinationCity, DepartureDate, ReturnDate, SSN)
EXPENSES (TripId, Item, Date, Amount)
[10 pts]
7. a) Underline the appropriate attribute(s) of the primary key for the relation TRIPS.
b) Underline the appropriate attribute(s) of the primary key for the relation EXPENSES.
c) Draw arrows from foreign keys to their corresponding relation and attribute.
d) What candidate keys are there in the EMPS relation?
_________________________________________
8. Give Relational Algebra statements for the following queries on the 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
RENAME: relation[new attribute names]
ASSIGN: new-relation(attrs)  R.A. expression
|X|condition
a) List all names and phone numbers of people who earn more than $50000 in salary.
b) List employee names and job titles of those who are currently traveling. You can use NOW() to
refer to today.
CS 370 Spring 2017 Exam 1
Page 5
EMPS (SSN, name, address, zip, phone, deptno, jobTitle, salary)
CSZ (zip, city, state)
DEPTS (deptno, deptName, deptMgrSSN)
TRIPS (TripId, DestinationCity, DepartureDate, ReturnDate, SSN)
EXPENSES (TripId, Item, Date, Amount)
c) List all the expense items, dates, amounts and destination city for employee John Dough..
d) List employee names from the Accounting department who have not traveled traveled (Hint: join
after set difference).
e) List employee names who have traveled to Paris at least twice. (Hint: self-join)