Sunteți pe pagina 1din 6

MSIT-IIIT DBMS Week-1 Exam Date: Dec 22, 2012 Time: 3 hours 30 minutes Max Marks: 100 Note:

Brief and accurate answers are expected. Unnecessary and unrelated content in your answers are heavily penalized. Section A (70 M) 1. Why would you choose a database system instead of simply storing the data in Operating system files? (5M) Answer: Using a DBMS to manage has many advantages: Data Independence: Efficient Data Access: Data Integrity and Security: Data Administration: Concurrent Access and Crash Recovery: Reduced Application Development Time Note: Give one mark for each of the above advantages. Max is 5 2. What is meant by data modeling?(5M)
Answer: A data model is a collection of high-level data description constructs that hide many low-level storage details. A DBMS allows a user to define the data to be stored in terms of a data model. Most database management systems today are based on the relational data model Note: If they write which have meaning similar to first sentence, give full marks.

3. Differentiate Logical Modeling and Physical Modeling.(6M)


Answer: The conceptual schema (sometimes called the logical schema) describes the stored data in terms of the data model of the DBMS. In a relational DBMS, the conceptual schema describes all relations that are stored in the database. The physical schema specifies additional storage details. Essentially, the physical schema summarizes how the relations described in the conceptual schema are actually stored on secondary storage devices such as disks and tapes. We must decide what file organizations to use to store the relations and create auxiliary data structures, called indexes, to speed up data retrieval operations. Note: If they write which have meaning similar to bold part of the above answer, give full marks.

4. Define the following and give an example for each.(10M) o Entity o Relationship between two Entities o Ternary Relationship o Weak Entity in a relation o Aggregation in a relationship Answer: Entity: An entity is an object distinguishable from other objects and represented by a set of attributes. Relationship: an association among several entities Ternary Relationship: A relationship is said to be a ternary relationship type if three entity types are involved in that relationship. Weak Entity in a relation: In a relational database, a weak entity is an entity that cannot be uniquely identified by its attributes alone; therefore, it must use a foreign key in conjunction with its attributes to create a primary key.

Aggregation in a relationship: An object is related to the components that make it up via the ispart-of relationship 5. Define and give an example for each of the following. (12+2) i) Primary key ii) Super key iii) Candidate key iv) Minimal key v) Composite key vi) Foreign key Which of the above keys are unique? Answer: Primary key - a primary key is a value that can be used to identify a unique row in a table. Candidate key - A candidate key is a field or combination of fields that can act as a primary key field for that table to uniquely identify each record in that table. Composite key - compound key (also called a compound key or concatenated key) is a key that consists of 2 or more attributes. Superkey A superkey is a set of fields that contains a key. Or A superkey is defined in the relational model as a set of attributes of a relation variable (relvar) for which it holds that in all relations assigned to that variable there are no two distinct tuples (rows) that have the same values for the attributes in this set. Equivalently a superkey can also be defined as a set of attributes of a relvar upon which all attributes of the relvar are functionally dependent. Minimal Key: A minimal set of attributes which can become a key is called minimal key. Foreign key - a foreign key (FK) is a field or group of fields in a database record that points to a key field or group of fields forming a key of another database record in some (usually different) table. A primary key is unique. 6. Describe about the Key Constraints in Data Modeling with an example for each.(6M) Answer: Give full marks if they write about Unique key constraints and Foreign Key Constraints. General and integrity constraints are not related with key constraints. 7. Describe the principles and detailed steps involved in mapping ER diagrams to relations.(6M) Answer: Steps to convert ER Model into Relational Model: A. Divide the information into tables - Divide your information items into major entities or subjects, such as Products or Orders. Each subject then becomes a table. B. Turn information items into columns - Decide what information you want to store in each table. Each item becomes a field, and is displayed as a column in the table. For example, an Employees table might include fields such as Last Name and Hire Date. C. Specify primary keys - Choose each tables primary key. The primary key is a column that is used to uniquely identify each row. An example might be Product ID or Order ID. D. Set up the table relationships - Look at each table and decide how the data in one table is related to the data in other tables. Add fields to tables or create new tables to clarify the relationships, as necessary. E. Refine your design - Analyze your design for errors. Create the tables and add a few records of sample data. See if you can get the results you want from your tables. Make adjustments to the design, as needed.

8. Why normalization is important to stable database design with the relational model? List the conditions that a relational table is to satisfy 1NF, 2NF, 3NF and BCNF. (2+8)

Answer: It encompasses a set of procedures designed to eliminate nonsimple domains (nonatomic values) and the redundancy (duplication) of data, which in turn prevents data manipulation anomalies and loss of data integrity. Or Database normalization is the process of organizing the fields and tables of a relational database to minimize redundancy and dependency. Normalization usually involves dividing large tables into smaller (and less redundant) tables and defining relationships between them. The objective is to isolate data so that additions, deletions, and modifications of a field can be made in just one table and then propagated through the rest of the database via the defined relationships.

1NF : A relation R is in first normal form (1NF) if and only if all underlying domains contain atomic values only 2NF: A relation R is in second normal form (2NF) if and only if it is in 1NF and every non-key attribute is fully dependent on the primary key 3NF: A relation R is in third normal form (3NF) if and only if it is in 2NF and every non-key attribute is non-transitively dependent on the primary key. BCNF: A relation R is in Boyce-Codd normal form (BCNF) if and only if it is in 3NF and if every determinant is a candidate key

9. Give an example for each of the following (8M) a) 1NF but not 2NF b) 2NF but not 3NF c) 3NF but not BCNF d) BCNF Note: Examples may not be unique. Please verify whether the given examples by the students make sense. Answer: Example: 1NF but not 2NF Consider the following inventory record:
--------------------------------------------------| PART | WAREHOUSE | QUANTITY | WAREHOUSE-ADDRESS | ====================-------------------------------

The key here consists of the PART and WAREHOUSE fields together, but WAREHOUSEADDRESS is a fact about the WAREHOUSE alone.

Example (2NF but not 3NF):


| EMPLOYEE | DEPARTMENT | LOCATION | ============------------------------

The EMPLOYEE field is the key. If each department is located in one place, then the LOCATION field is a fact about the DEPARTMENT -- in addition to being a fact about the EMPLOYEE.

To satisfy third normal form, the record shown above should be decomposed into the two records:
------------------------| EMPLOYEE | DEPARTMENT | ------------------------| DEPARTMENT | LOCATION |

Example (3NF but not BCNF): Consider the following non-BCNF table whose functional dependencies follow the {AB C, C B} pattern: Nearest Shops Person Shop Type Nearest Shop Davidson Optician Wright Fuller Fuller Fuller Eagle Eye Davidson Hairdresser Snippets Bookshop Merlin Books Bakery Optician Doughy's Eagle Eye Hairdresser Sweeney Todd's

For each Person / Shop Type combination, the table tells us which shop of this type is geographically nearest to the person's home. We assume for simplicity that a single shop cannot be of more than one type. The candidate keys of the table are:

{Person, Shop Type} {Person, Nearest Shop}

Because all three attributes are prime attributes (i.e. belong to candidate keys), the table is in 3NF. The table is not in BCNF, however, as the Shop Type attribute is functionally dependent on a non-superkey: Nearest Shop. Example:(BCNF ): The violation of BCNF means that the table is subject to anomalies. For example, Eagle Eye might have its Shop Type changed to "Optometrist" on its "Fuller" record while retaining the Shop Type "Optician" on its "Davidson" record. This would imply contradictory answers to the question: "What is Eagle Eye's Shop Type?" Holding each shop's Shop Type only once would seem preferable, as doing so would prevent such anomalies from occurring: Shop Near Person

Person Davidson Davidson Wright Fuller Fuller Fuller Eagle Eye Snippets Merlin Books Doughy's Sweeney Todd's Eagle Eye

Shop

Shop Shop Eagle Eye Snippets Merlin Books Doughy's Shop Type Optician Hairdresser Bookshop Bakery

Sweeney Todd's Hairdresser In this revised design , the "Shop Near Person" table has a candidate key of {Person, Shop}, and the "Shop" table has a candidate key of {Shop}.

Section B (30 M) 1. Design a database for a bank, including information about customers and their accounts. Information about a customer includes their name, address, phone, and Social Security number. Accounts have numbers, types (e.g., savings, checking) and balances. We also need to record the customer(s) who own an account. Draw the E/R diagram for this database. Be sure to include arrows where appropriate, to indicate the multiplicity of a relationship. (10M)

Answer:

2. Convert the E/R diagram given below to a relational database schema. Normalize tables till they satisfy BCNF. (Unless your tables are in 3NF you will not get any marks for table creation) (20M)

Answer:
Customers(ssNo, name, addr, phone) Flights(number, day, aircraft)

Bookings(ssNo, number, day, row, seat) Being a weak entity set, Bookings' relation has the keys for Customers and Flights and Bookings' own attributes

S-ar putea să vă placă și