Upload
santhosh-kiran-reddy
View
217
Download
0
Embed Size (px)
Citation preview
7/30/2019 dfdffedfdrerererefef
1/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 Operatingsystem 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: Adata modelis 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 therelational 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 interms 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 devicessuch 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 Entityo Relationship between two Entitieso Ternary Relationshipo Weak Entity in a relationo 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.
http://en.wikipedia.org/wiki/Relational_databasehttp://en.wikipedia.org/wiki/Foreign_keyhttp://en.wikipedia.org/wiki/Primary_keyhttp://en.wikipedia.org/wiki/Primary_keyhttp://en.wikipedia.org/wiki/Foreign_keyhttp://en.wikipedia.org/wiki/Relational_database7/30/2019 dfdffedfdrerererefef
2/6
Aggregation in a relationship: An object is related to the components that make it up via the is-
part-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 keyv) 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 keyfield 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.
SuperkeyA 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 torelations.(6M)
Answer: Steps to convert ER Model into Relational Model:
A. Divide the information into tables - Divide your information items into major entities orsubjects, such as Products or Orders. Each subject then becomes a table.
B. Turn information items into columns - Decide what information you want to store ineach 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 columnthat 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 tableis related to the data in other tables. Add fields to tables or create new tables to clarifythe relationships, as necessary.
E. Refine your design - Analyze your design for errors. Create the tables and add a fewrecords 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?Listthe conditions that a relational table is to satisfy 1NF, 2NF, 3NF and BCNF. (2+8)
7/30/2019 dfdffedfdrerererefef
3/6
Answer: It encompasses a set of procedures designed to eliminate nonsimple domains (non-
atomic 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 thefieldsandtablesof arelational
databaseto minimizeredundancyand 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 ifevery determinant is a candidate key
9. Give an example for each of the following (8M)a) 1NF but not 2NFb) 2NF but not 3NFc) 3NF but not BCNFd) 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 WAREHOUSE-
ADDRESS 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 theLOCATION field is a fact about the DEPARTMENT -- in addition to being a fact about the
EMPLOYEE.
http://en.wikipedia.org/wiki/Field_%28computer_science%29http://en.wikipedia.org/wiki/Field_%28computer_science%29http://en.wikipedia.org/wiki/Field_%28computer_science%29http://en.wikipedia.org/wiki/Table_%28database%29http://en.wikipedia.org/wiki/Table_%28database%29http://en.wikipedia.org/wiki/Table_%28database%29http://en.wikipedia.org/wiki/Relational_databasehttp://en.wikipedia.org/wiki/Relational_databasehttp://en.wikipedia.org/wiki/Relational_databasehttp://en.wikipedia.org/wiki/Relational_databasehttp://en.wikipedia.org/wiki/Data_redundancyhttp://en.wikipedia.org/wiki/Data_redundancyhttp://en.wikipedia.org/wiki/Data_redundancyhttp://en.wikipedia.org/wiki/Data_redundancyhttp://en.wikipedia.org/wiki/Relational_databasehttp://en.wikipedia.org/wiki/Relational_databasehttp://en.wikipedia.org/wiki/Table_%28database%29http://en.wikipedia.org/wiki/Field_%28computer_science%297/30/2019 dfdffedfdrerererefef
4/6
To satisfy third normal form, the record shown above should be decomposed into the tworecords:
------------------------- -------------------------
| 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 Eagle Eye
Davidson Hairdresser Snippets
Wright Bookshop Merlin Books
Fuller Bakery Doughy's
Fuller Hairdresser Sweeney Todd's
Fuller Optician Eagle Eye
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 in3NF. 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 Eyemight 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 Shop
Davidson Eagle Eye
Davidson Snippets
Wright Merlin Books
Fuller Doughy's
Fuller Sweeney Todd's
Fuller Eagle Eye
7/30/2019 dfdffedfdrerererefef
5/6
Shop
Shop Shop Type
Eagle Eye Optician
Snippets Hairdresser
Merlin Books Bookshop
Doughy's 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 arelationship. (10M)
Answer:
2. Convert the E/R diagram given below to a relational database schema. Normalize tablestill 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)
7/30/2019 dfdffedfdrerererefef
6/6
Bookings(ssNo, number, day, row, seat)
Being a weak entity set, Bookings' relation has the keys for Customers and Flights and Bookings'
own attributes