You are on page 1of 6

SCHOOL OF COMPUTER SCIENCE AND ENGINEERING

CAT – I
CSE 2004 – Database Management Systems
Course Name: B.Tech Slot: D1 Max. Marks: 50
Answer ALL Questions (5 * 10 = 50)
1. a. List out any five disadvantages of a file based system. (5)

 Data Redundancy and inconsistency


 Difficulty in accessing data – program needs to be changed every time
 Data isolation –Different file formats
 Integrity problems – Checking constraints
 Atomicity problems – Commit and Rollback
 Concurrent access anomalies
a. Security problems – Data views

b. What is the difference between logical data independence and physical data
independence? Which one is harder to achieve? Why? (5)

Logical Data Independence:


• Logical data independence is the capacity to change the conceptual schema without
having to change external schemas or application programs. We may change the
conceptual schema to expand the database (by adding a record type or data item), to
change constraints, or to reduce the database (by removing a record type or data item).
In the last case, external schemas that refer only to the remaining data should not be
affected
• Physical data independence is the capacity to change the internal schema without
having to change the conceptual schema. Hence, the external schemas need not be
changed as well. Changes to the internal schema may be needed because some
physical files were reorganized—for example, by creating additional access
structures—to improve the performance of retrieval or update. If the same data as
before remains in the database, we should not have to change the conceptual schema

Logical data independence is harder to achieve because it allows structural and


constraint changes without affecting application programs—a much stricter
requirement.
2 .a. As per the rules of the firm
 Every product should have a name (1)

Ans: Product name should be altered to have the not null constraint
SQL Query
alter table product modify product_name not null;
Every product should have a Product code that is distinct and the length of the product
code should be equal to six digits (2)
Ans:
Product code should be made primary key and a check constraint should be
applied on the column to check for length to be six digits.

SQL> alter table product add


2 (constraint product_code_pk primary key(product_code),
3 constraint product_code_ck check (length(product_code)=6));

 Product quantity should be zero or greater than zero and less than 200. (2)
Ans Check constraint should be applied on product quantity as shown
alter table product add constraint product_check_ck check(quantity>=0 and
quantity<=100);

How can you limit the entry of such ambiguous data in to the table at the database level?
Illustrate with Constraints.
b. Which of the following plays an important role in representing information about the real
world in a database? Explain briefly. (5)

o The data definition language.


o The data manipulation language.
o The bu er manager.
o The data model.

3.a. What are the responsibilities of a DBA? If we assume that the DBA is never interested in
running his or her own queries, does the DBA still need to understand query optimization?
Why? (5)

The DBA is responsible for:


Designing the logical and physical schemas, as well as widely-used portions of the external
schema. Security and authorization. Data availability and recovery from failures. Database
tuning: The DBA is responsible for evolving the database, in particular the conceptual and
physical schemas, to ensure adequate performance as user requirements change.
A DBA needs to understand query optimization even if s/he is not interested in running his or
her own queries because some of these responsibilities (database design and tuning) are
related to query optimization. Unless the DBA understands the performance needs of widely
used queries, and how the DBMS will optimize and execute these queries, good design and
tuning decisions cannot be made.
b. Model an ER diagram for the scenario given below (5)

Students are assigned to proctors. Every proctor can be assigned maximum of 20 students.
Every student should have a guardian. Students can have maximum of 2 guardians.
Guardians are allowed to register multiple phone numbers. Students should register for
courses and every course is offered in several venues and slots.

Student
m
1

20
Registe
has
Phone rs
Slot

Assigne
2 d
Venues

Gaurdian 1 Course
Proctor
4. Map the given ER model to relational schema. Identify all the Constraints. (10)

Answer:
CUSTOMER

ID NAME ADDRESS MOBILE


NUMBER

 Customer name and address are composite attributes. They may be given in separate tables
with reference in Customer Table (ID)

EMPLOYEE

EMP ID VENDOR MOBILE


ID NUMBER

 Employee name is a composite attribute. (same as the above case)

VENDOR
VENDOR ID VENDOR NAME LOCATION CONTACT
NUMBER

PRODUCT

PRODUCT PRODUCT UNIT PRODUCT UPGRADE


ID NAME PRICE CATEGORY (PRODUCT
ID ID)

SUPPLIER INFO

PRODUCT VENDOR
ID ID

ORDER

ORDER CUSTOMER ORDER DELIVERY


ID ID DATE DATE

ORDER DETAILS

ORDER PRODUCT QUANTITY DELIVERY


ID ID ID

BILL

BILL ID BILL CUSTOMER BILL ORDER


DATE ID AMOUNT ID

DELIVERY

DELIVERY ID DELIVERY TYPE CHARGES


5. a) Answer the following (5)

i. Is it mandatory for a foreign key to be a primary key in another table?


Ans: Yes a Foreign key should be a primary key in the parent table
ii. Can foreign keys be null values in the child relation?
Yes Foreign Keys can be null in the child relation
iii. After enforcing foreign key constraint using on delete cascade rule, Can you
delete the record in the child relation whose foreign key is not null before deleting
the record in the parent relation?
No .Deleting of child records before deletion of the parent record is not
allowed after enforcement of a foreign key constraint
iv. Can foreign keys have duplicate values?
Yes foreign keys can have duplicate values
v. Can there exist more than one foreign key in a relation?
Yes there can exist multiple foreign keys in a relation.

b) Reason out why Parent Keys Not Found Error occur during the enforcement of
foreign keys and how will you fix it with a suitable example. (5)

Parent keys not found errors occurs when a value present in the foreign key column is
not present in the primary key column of the parent table. It is illustrated with the example
given below

Student

Registration Number Name School ID [Foreign Key]


1 Sam 456
2 Ram 458

School

ID School Name Location


456 SCOPE SJT

Since School id 458 is not present in the parent table we get the parent keys not found error.
The error can be fixed by removing the bad data from the child table.

You might also like