MCS-23 ASSIGNMENT (2010-11)
This assignment has four questions, which carries 80 marks. Answer all
questions. Rest 20 marks are for viva voce. You may use illustrations and
diagrams to enhance the explanations. Please go through the guidelines
regarding assignments given in the programme guide for the format of
presentation. Answer to each part of the question should be confined to
about 300 words.
Question 1:
(i) “For creating a student information management system of a
University a database management system is better than that of file
management system.” Justify the statement given above. Now,
assume that you are assigned the role of database administrator for
the University database. What are the key responsibilities you have to
handle?
Ans. For creating a student information management system of a University
by the normalization.
Enroll No. S.Name Dept Year Block Name
1124 Mathews Physics 1 G
1126 John Chemistry 1 G
1016 Bill Math 2 K
1420 James Botany 2 K
1503 Charles Zeology 4 L
A second normal form if every relation scheme include in the database
scheme is in second normal form.
UNIVERSITY (Uni_name, Uni_id, Uni_add)
STUDENT (S_roll no., S_name, S_address, sex)
CLASSROOM (capacity, Room no., Location)
EXAM (Exam_subs, Date of exam)
EXA-CENTRE (address, phone no.)
1
EMPLOYEE (ssn, e.sex, e_salary, e_name, e_add)
Entities and their attributes refer the full information of student in a
University. Database management system is better than file
management system because the database system contains not only
database itself but also a complete definition or description of
database structure and constraints. The information stored in the
catalog is called meta_data.
When file management system is supported by a conventional
operation system. This system stores permanent records file in various
file and it needs different application program to extracts records from
and ass records to appropriate file. So it has proved that database
management system is better than file management system. A key
allows us to identify a set of attributes that suffice to distinguish
entities from each other. Keys also help unequally identify relationship.
The attribute student registration no unequally identify the instance of
the entity set student, this unique identify called primary key.
These keys are called primary key, super keys, candidate keys,
alternate keys.
A secondary key is an attribute or combination of attribute that may
not be a candidate key but they classify the entity set on a particular
characteristic.
(ii) Draw an ER diagram for a system having the following requirements:
A University maintains data of its students, the progarmmes they are
registered in and the address information of the students. A
programme consists of many sources. The database needs to store the
programme duration and fees. A course has a number of credits
associated with it and may be the part of more than one programmes.
Some of the constraints that may be assumed for the University
database system are:
• A student can taken only one programme at a time.
• A course may be part of more than one programme.
2
• The duration of the programme is in semester. A course is taught
in atypical semester of the programme.
List all the entity sets, attributes of each entity sets and relationship
sets. Draw the E-R diagram for the requirements as listed above for the
database system. You may use the concept of keys, cardinality etc. in
a proper way. Make and state suitable assumptions, if any.
y
r
x d
l a
e d
n l
s a
Uni.id
s a
_ _
Uni,na Uni.a s
E
s
E
me dd _
E
Work
UNIVERSITY EMPLOYEE
Ans. For
cont Addre
Cond rol
Regis ss
uct
ter Exam_su Phone
m no.
Exam Date of Exa_Center
exam
H
App a
ear s
Class Room
STUDENT
s. .
y. n
. s o
e t o
o e n
m ci ti
n r x a a
a m
l e
3
N d p c
ol d S o
_ a o
_r a o
S C L
S R
S
4
(iii) Create the relations from the E-R diagram that you have drawn for part
(ii). The relations must be at least in 2NF. You must do the following
with the relations
a) Enter about 5 sets of meaningful data in each of the relations
b) Identify the domain of various attributes
c) Identify the primary keys of all the relations
d) Identify the foreign keys and referential integrity constraints
integrity constraints in the relations.
Ans. A database schema is in second normal form. If every relation scheme
included in the database scheme is in second normal form.
Even though 2NF not permit the partial dependency but does not
remove transitive dependency.
FD
Enroll No. S. Name, Dept, Year, block Name
S_Name Enrol no., Dept, year, Block Name
Dept Enrol No., S.name, Year, Block name
Year Block Name
Block NameYear
Above relation is in 2NF because all non prime attributes are fully
functionally dependent on the relation key (say enroll no) but there is
still transitive dependency is
Enrol year, year Block name
(iv) Perform the following tasks using relational algebraic operations for the
relations created at part (iii):
(a) List all the courses of MCA programme.
(b)Find the student name, programme code and the programme duration
of the programme in which s/he is registered.
(c) Find the list of students in BCA programme.
5
Ans. PROGRAM (course_id, course_code, course_name, course_title)
STUDENT (student_id, name, address, deptt)
LECTURES (lectures_id, student_id)
(PK) = Course_id
(PK) = Student_id
FK = Lecture_id, references (student)
The following are some different ways of stating this query in SQL.
SQL > Select std_name, course_name
FROM student, registration, std#
COURSE course# registration, course#
REGISTRATION course# in
SELECT C2 course #
FROM course C2 wfere C2 course # > 300 and cl. Course # = C2.
Course #
Question 2:
(i) What are the problems associated with data Redundancy in a relation?
How can you solve those problems? Can referential integrity
constraints help in addressing those problem? Give reasons in support
of your answer.
Ans. DATA REDUNDANCY : In file processing system the same copy
of data are stored more than once is called data redundancy. I large
organization the same information may be duplicate in several place.
For example the address and telephone no. of particular customer may
appear in file that consists of saving account records.
We can solve this problem by the normalization yes referential
integrity constraints help in addressing those problem.
Given two relations R & S, suppose R refers to the relation S via a set
of attribute that form the primary key of S and this set of attributes
6
forms a forign key in R. Then the value of the forign key in a table in R
must either be equal to the primary keys of table of S or be entirely
NULL.
a) INSERTION
b) DELETION
c) UPDATION
(ii) Consider the following employee record in an organization
Employee (ID, name, date of joining, age, address, department,
manager, ID’s of projects working on, role in the project, project
name, project team leader, duration of project, dependent names)
An employee works in one department. Each department is managed
by one manager. An employee can work on many projects. A projects
has team leader. An employee can have many departments, however,
one department can be related to only one employee.
Identify the functional dependencies in the relation given above.
Normalize the relational up to BCNF. Make suitable assumptions, if
any
Ans.
E_id E_name Date of Birth Date Joining Age Dep Head
t
E1 N1 1980 B1 30 D1 E1
E2 N2 1981 B2 29 D2 E2
E3 N3 1982 B3 28 D3 E3
E4 N4 1983 B4 27 D4 E4
E5 N5 1984 B5 26 D5 E5
Some relations schemas, even though they are in BCNF
Do not be sufficiently normalized in the sense that they will suffer from
problem of repetition information consider
7
BC_schema=(E.id, E_name. E_address, E_age)
Anyone will recognize this schema as a non BCNF scheme because
of functional dependency.
E_name E_date of joining, E_date of birth. After
decomposition of employee into Emp & Dept. EMP_ No is the
primary key. Depart_head is functionally dependent of Emp_id.
Emp_id Deptt Deptt- head
(iii) Compare and contrast the features of sequential, indexed and
hashed file organizations. Consider the problem(ii) in this question; propose
a suitable file organization for each of the relation created. Justify your
selection of file organization.
Ans. Sequential file organization: A sequential file is designed for efficient
processing records in sorted order based on some search key.
a) Records are stored in sequential order according to search keys value.
b) A search key is any attribute or set of attribute, it may or may not be
primary key.
c) To access records easily & fastly pointer are used to chain records.
d) To minimize no. of block accesses, we store records physically in
search key order.
e) A sequential file organization allows records to be read in stored
order.
Roll No. Name
1 Asit Pointer to next
2 Neeraj
records
3 Shoumya
4 Jetender
8
End of record
f) For insertion & deletion in sequential file organization pointer are
needed to be managed.
INDEX FILE ORGANIZATION : An index is a set of key that is used to
search a record in a memory. The purpose of indexing is to provide
the fast searching of records. An index for records in system work in
much the same way as the catalog for a book in library.
The arrangement of index information is based on key of index
information is based on key of index. Index file provide the quick
search facility, improves the performance of the query.
HASHED : In direct file organization the physical location of records is
based on some relationship with its primary key value. Here key value
maped directly to the storage location. This process is called hashing.
KEY HASH
ADDRESS
VALUE FUNCTION
Let us consider a hash function h that maps the key value k of the
value h(k) that is address ares of records lies between some range
suppose s1 and s2
S1 < n (k) < S2
The simple hash function is
h (k) = k mod s
where S = supper address bucket value_lower bucket address value
+2
(iii) Consider a relation student(ID: 9 characters) having about 1,000,000
students records. The database is stored on a disk having a disk
9
block size of 1 MB. Assume that the primary index of the relation is
ID and its relation is required mostly for the application that
generates programme wise list of student names in alphabetical
order. Create a secondary index that will improve the performance
of the system for the given application. Show how many block
transfers will saved on average due to creation of index. Make
suitable assumptions if any.
Ans. PRIMERY INDEX : Primary Index is an ordered files whose records
are fixed length with two fields. The first field is of the same data
type as the ordering key field called the primary key of the data file
and the record field is a pointer to a disk block (a block address).
There is one index entry in the index file for each block in data file.
Name S_id D.Birth Deptt Pr_code
Aron
Abolt
Ascolta
Block Anchor Block
Primary Key Pointer
Aoron .
Acolon .
Allen .
: .
Wrigth .
10
Adam
R.robin
Akess
Allen
Andew
Aluson
Wrigth
Wyth
Zewin
Secondary index is also in ordered file with two fields. The first field is the
same data type as some non ordering field of the data five that is in index
field. The second field is either block recorder pointer.-
Secondary Key
Index field value Block Pointer
9
1 .
2 . 5
3 . 13
4 . 8
5 6 .
6 15 .
7 3 .
8 .
17
9 . 21
14
10 . 16
11 . 2
17 .
12
18 ..
13
19 .. 24
10
14
20 ..
20
15
21 12
4 .. 1
16
22 23
7 ..
11
23 18
19 .
24 14
22 .
Question 3:
(i) Consider the following relations
Account(ac_number,ac_holdername,ac_holderaddress,ac_balance)
Withdrawal(ac_number,wi_type,wi_date,wi_amount)
Deposit(as_number, de_by,de_date, de_type,de_amount)
Type of deposit or withdrawal may be –cash or cheque
Perform the following operations on these tables using SQL
a. Create the three tables giving suitable domains and constraints
including referential actions.
b. Add one additional filed ac_type(it can be saving account, current
account or student account) in the accounts table. Create a
secondary index on ac_number for the withdrawal and deposit
tables.
c. Create a view named my_account that contains the information
about my account.
d. Give only READ only permission to see my_account view to a user.
Ans. (select ac_number:
From account)
(select ac_number)
From deposit
(select ac_number
From withdrawal)
Use of null value causes several complications which are
described as follows.
The result of an arithmetic expression (+, -, *, /) is null if any of value
is null.
12
(ii) Perform the following queries using SQL for the relations of part(i):
a. Find the list of the account holders whose account balance is less
than Rs.1000/-
b. Find the details of those account holders who have withdrawal nore
than Rs.1,00,000/- in the last month.
c. Find the sum of deposits that has been credited in each account in
the last year.
d. Find an account holder who has not withdrawn any money in the
last year.
Ans. The statement is used to change a value in a table without effecting
other value.
Eq.
Update account
Set balance = balance Lessthan 1000
Select max (tot_balance)
From(select branch_name, sum(balance))
From account
Group by branch name as branch_total
(branch_name, total balance)
Select account number
From account, max balance
Where account, balance = max balance, value.
(iii) Write the psedocode for the withdrawal and deposit transactions for
the schema of the bank given in this question. Use two phase locking
13
protocol and lock the data items suitably such that there is no
concurrency related problem in the database.
Ans.
Ac_ Addr Deposit
Amount
id ess form
Na Cit
me y
Account Acco
unt Deposite
Holder
Bank
Officer
With drawal
Acc.
Addres
Name
s
14
F/G-
A schema is a logical database description & is drawn as a chart of the type
of data that are used. It gives the name of entities and attributes and specify
the relationship between them.
(iv) What is a deadlock? How can you detect deadlock? Explain with the
help of a wait for graph. What are the possibilities that the deposit
and withdrawal transactions as created in part (iii) will result into
deadlock? Explain your answer.
Ans. DEADLOCK : An concurrent mode of operation each running
transaction is allowed to exclusively claims one or more set of
resources. Due to this two kind of problem arises deadlock and
------------.
Let us consider there are ‘n’ number of concurrent transaction (Ta, Tb--------
Tn) and m number of resource (ra, rb, ----- rm) that can be shared.
DEADLOCK DETECTION
A deadlock occurs whenever there is a circular chain of transaction, each
waiting for release of data item held by next transaction in the chain.
In order to detect a deadlock system must be the following information.
a. Current set of transaction
b. Current allocation of data items to each of transaction.
c. Current set of data items for which each of transaction is waiting.
Transaction Data item locked Data item waiting for
T1 B C, A
T2 C, M H, G
T3 H D, E
T4 G A
T5 A, E C
T6 D, I F
Question 4:
15
(i) Consider the database schema of Question 3. Create sample
transaction log for the transactions that you have defined in Q3 part
(iii). Explain how this log may be used to recover from failure.
Ans. A schema is a logical database description & is drawn as a chart of
the types of data that are used. It gives the names if entities and
attributes and specify the relationship between them.
VIEW OF DATA : A database collection of inter related files and set of
programs that allows user to access and modify these files. A major
purpose of a database system is to provide users with an abstract view
of database system is to provide user with an abstract view of data that
the system hides certain details of how the data are stored and
maintain.
Two levels are used to maintain the data
a. Physical Level
b. Logical Level
VIEW
VIEW VIEW LEVEL
VIEW 3
1 2
LOGICAL
LEVEL
PHYSICAL
LEVEL
16
Level of data abstract
(ii) Consider the database schema of Question3, suggest at least two
different types of users for the system. You may use my_account view
for one of the users. Create an authorization matrix for the relations.
Make suitable assumptions, if any.
Ans. A relation schema that contains the information about account
maintained by the bank. Customer (cust_id, branch, account,
customername balance)
ID BRANCH ACCOUNT CUSTOMER NAME BALANCE
1 Bombay 305 Brijesh 15000
2 Bombay 475 Ajay 10000
3 Delhi 786 Naresh 5000
4 Jaipur 492 Rajesh 12000
(iii) Now, assume that the bank schema as given in Question 3 is being
implemented using distributed database. Suggest suitable data
fragmentation needed for this distributed database.
Ans. Consider the relation schema deposit (id, branch, account, customer
name, balance)
The entire of above relations?
ID BRANCH ACCOUNT CUSTOMER NAME BALANCE
1 Bombay 305 Brijesh 15000
2 Bombay 475 Ajay 10000
3 New Delhi 786 Naresh 5000
4 Jaipur 492 Rajesh 12000
The horizontal fragmentation of relations
17
ID BRANCH ACCOUNT CUSTOMER NAME BALANCE
1 Bombay 305 Brijesh 15000
2 Bombay 475 Ajay 12000
ID BRANCH ACCOUNT CUSTOMER NAME BALANCE
3 Delhi 786 Naresh 5000
4 Jaipur 492 Rajesh 12000
Vertical fragmentation of the relations are
ID BRANCH CUSTOMER ID ACCOUNT BALANCE
NAME 1 305 15000
1 Bombay Brijesh 2 475 10000
2 Bombay Ajay 3 786 5000
4 492 12000
3 New Delhi Naresh
(iv) Compare and contrast the two tier model to that of 3 tier model client
server architecture. Can you implement the database given in
question 3 as a 3 tier model? Explain your answer.
Ans. Client/server Computing: In a computer system based client server
model. Client server model is a concept for describing communication
between service consumer knowledge as client and service provider
called server. The deferring feature of this model is that a client
initiates and interaction with a server by sending a message or by
involving an operation likewise the response for a server is a message
that is sent back to like client. This basic representation.
CLIENT SERVER
Executive
Sent reqest
Response
Want
Sent reply
Receive reply
18
A client/server computing can have more than on server and clients.
CLIENT CLIENT CLIENT
1 2 3
NETWORK
File File
Server Server
19