0 ratings0% found this document useful (0 votes) 628 views173 pagesDatabase Management System
Database Management System Makaut Organizer of 2023-24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
DATABASE MANAGEMENT
SYSTEMS
Database System Architecture 2
Entity-Relationship Model 8
Relational Model 25
SQL 39
Functional Dependencies and Normalization 55
Storage Strategies 89
Transaction Processing 101
Database Security 127
130
Advanced TopicsPOPULAR PUBLICATIONS
DATABASE SYSTEM ARCHITECTURE
4. Which defining a numeric number field that can hold 3 digits before the decimal
point and 3 digits after the decimal points, the width would be given “weur 201%)
a6 b)7 8 d)3
Answer: (a)
2. The data dictionary tells the DBMS [WBUT 2012]
a) what files are in the database
b) what attributes are possessed by the data
c} what these files contain
d) all of these
Answer: (¢)
3. The employee salary should not be greater than Rs 20,000. This is
[WBUT 2044, 2017]
a) integrity constraint b) referential constraint
¢) over-defined constraint d) feasible constraint
Answer: (2
4, The information about datain a database is called [WBUT 2017]
a) Metadata b) Teradata .
¢) Hyperdata d) None of these
Answer: (2)
5. Tree structures are used to store data in
a) network moe}
¢) hierarchical mode!
Answer: (b)
[WBUT 2018]
b) relational model
d) file based system
Short Answer Type Questions
1. Describe the three-schema architecture, [WBUT 2006)
OR,
Explain in brief 3-schema architecture of DBMS. (WBUT 2013]
OR,
Describe three layer architecture of DBMS,
OR, (WBUT 2013)
Describe Three-Schema architecture of DBMS. (WBUT 2015)
DBMSCS-2Answer:
Three Schema Architecture of DBMS
Mapping supplied by
DBMS
CONCEPTUAL LEVEL
ey a
‘The three levels of the architecture
¢ The internal level is the one closest to physical storage —i.e., it is the one concerned
with the way the data is physically stored.
¢ The conceptual level is a "level of indirection" between the other two. (Gives
abstraction on to the upper level of the lower level)
¢ The external level is the one closest to the users i.e., it is the one concerned with the
way the data is viewed by individual users.
If the external level is concemed with individual user views, then the conceptual level is
concemed with a community user view. In other words, there. will be many distinct
external views, each consisting of a more or less abstract representation of some portion
of the total database, and there will be precisely one conceptual view, consisting of a
similarly abstract representation of the database in its entirely. There will be precisely one
internal view, representing the total database as physically stored.
2. What are the main functions of a database manager? List five major functions of
Data Base Administrator. oR [WBUT 2006]
Explain the roles of adatabase administrator (DBA). [WBUT 2009]
Discuss the role of DBA. oe [WBUT 2017]
Explain the role of database administrator? [WBUT 2018]
Answer:
The functions of the DBA include the following:
(1) Schema definition: The DBA creates the original database schema by writing set of
definitions that is translated by the DDL compiler to a set of tables that is stored
permanently in the data dictionary.
(2) Storage structure and access-method definition: The DBA creates appropriate
storage structures and access methods by writing a set of definitions, which is translated
by the data-storage and data-definition-language compiler.
(3) Schema and physical-organitation modification: Programmers accomplish the
relatively rare modifications either to the database schema or to the description of the
physical storage organization by writing a set of definitions which is used by either the
DBMSCS-3POPULAR PUBLICATIONS
iler or the data-storage and data-definition-language compiler to generate
OO ie the appropriate intemal system tables (for example, the data dictionary),
(4) Granting of authorization for data access: The granting of different types of
authorization allows the database administrator to regulate which parts of the database
various users eon access, The authorization information is kept in special system
structure that is consulted by the database system whenever access to the data is
antempted in the system.
(5) Integrity-constraint specification: The data values stored in the database must satisfy
certain consistency constraints. Such a constraint must be specified explicitly by the
datahase administrator. The integrity constraints are kept in a special system structure
that is consulted by the database system whenever an update takes place in the system.
(6) Designing security and integrity constraint specification: The data values stored in
the database must satisfy certain consistency constraints. Such a constraint. must be
specified explicitly by the database administrator. The integrity constraints are kept in a
special system structure that is consulted by the database system whenever an update
takes place in the system.
(7) Routine Maintenance: Periodically backing up the data either onto some movable
devices and/or to remote servers to prevent and protect data from loss due to various
reasons. Also ensures free disk space for regular operations. Monitoring jobs running on
the database and ensuring that performance is not degraded by the method loosely called
performance tuning.
3. Write the difference between procedural and non-procedural DML. [WBUT 2006]
OR, :
What is the difference between procedural and non-procedural DML?
[WBUT 2013, 2017]
Answer:
DML language enable user to access or manipulate data as organized by appropriate data
model.
> Procedural DML or Low level: DML requires a user to specify what data are
needed and how to get those data.
* Non-Procedural DML or High level: DML requires a user to specify what data
arg needed without specifying how to get those data.
4. What is the difference between a database and a table? (WBUT 2009, 2011)
DBMSCS-4" DATABASE MANAGEMENT SYSTEMS.
5. Explain DDL, DML and DCL. ”
Answer: pea
Data Definition Language (DDL) :
A centus ren aneusee, f DDL) is used to describe the details of the data. The
i Specified by a set of definitions expressed by this special language.
The DBMS will have a compiler whose function is to process DDL statements in order to
identify description of the schema constructs and to store the schema descriptions as a set
of tables in a special file called data dictionary. Thus, data dictionary is a file that
contains data about ‘data which is called metadata. This file is consulted before actual
data are read or modified in the data base system.
Storage Definition Language: The SDL is used to specify the internal schema. The
mapping between two languages can be specified by any one of the languages. In some
DBMS, there is only one language which has both DDL and SDL capabilities.
To construct, modify and administer the database the following commands are used.
e CREATE Table
e ALTER TABLE
e DROP TABLE
Data Manipulation Language (DML)
Once the database schemas are compiled and the database is filled with data, the data
manipulation needs to covers the following functions:
1. The retrieval of information stored in the database.
2. The insertion of new information into the database.
3. The deletion of information from the database.
4. The modification of information stored in the database.
The language that enables the users to access or manipulate data is called the data-
manipulation language (DML). DML are of two types.
Procedural DML: which require users to specify what data are needed and how to get
those data.
Nonprocedural DML: which require a user to specify what data are needed without
specifying how to get it.
The following statements are used for data manipulation.
¢ SELECT is used to retrieve data from the table.
© UPDATE is used to modify the data in the table.
e DELETE is used to delete one or more records from a relation.
e INSERT is used to insert a new tuple into a specified relation.
Data Control Language (DCL)
DCL is used to control the data population. It enables users to specify the beginning and
ending of transactions. It deals with the authorization, access rights, recovery and
integrity issues. The following statements are used to control the data in the data base,
DBMSCS-5POPULAR PUBLICATIONS
Recovery and Concurrency:
¢ COMMIT
e ROLLBACK
Integrity Constraints:
Integrity constraints are enforced by the system. For example, one can specify that an
attribute of a relation will not accept null values. Detail syntaxes and examples are
discussed later.
6. Indicate the advantage of DBMS over conventional file system. [WBUT 2013]
Answer:
© Reduced data redundancy and Reduced updating errors and increased
consistency
© Greater data integrity and independence from applications programs
2 Improved data access to users through use of host and query languages
Improved data security
7. Could a modern university be supported if a file processing system was used to
manage enterprise information? List four major difficulties that are likely to arise if
no database system was available to the university. Discuss the difficulties.
[WBUT 2014)
Answer:
A modem university have to manage its large enterprise information because it can have
many departments, each with its own information system and data files. Three potential
problems exist in a file processing environment. The first problem is data redundancy,
which means that data common to two or more information systems is stored in several
places. Data redundancy requires more storage space and maintaining and updating data
in several locations is expensive. Second, data integrity problems can occur if updates are
not applied in every file. Changing the data in only one of the systems will cause
inconsistent data and result in incorrect information in the second system. The third
problem is the rigid data structure of a typical file processing environment. Businesses
must take decisions based on company-wide data and managers often require information
from multiple business units and departments. In a file processing environment, that
means retrieving information from independent, file-based systems, which is slow and
inefficient. Fourth is database system needs less storage. Theoretically, all occurrences of
data items need be stored only once, thereby climinating the storage of redundant data.
System developers and database designers often use data normalization to minimize data
redundancy.
DBMSCS-6DATABASE MANSGEMENTSYSTEMS
8. What is Data dictionary? IWBUT 2016]
Answer:
Data Dictionary: A data dictionary comains a list of all files in the database, the number
of records in each file, and the names and types of cach field. Most database management
systems keep the data dictionary hidden from users to prevent them from accidentally
destroying its contents. In other words it is known as meta data or data about the data.
Relational algebra is a procedural query language. which takes instances of relations as
input and yields instances of relations as output. It uses operators to perform queries. An
operator can be either unary or binary. The five fundamental unary operations are select,
project, Union, Set different and rename.
1. Gsutyect = “aatabase{ Books)
2. Tsujece author (Books)
3. TT eathor (Books) U TT autor (Articles)
4. TT author (BOOKS) — T] auctor (Articles)
5. px(E)
ng Answer Questions
1. Write a short note on Advantages of DBMS. [WBUT 2016]
Answer:
Advantages
© Reduced data redundancy
Reduced updating errors and increased consistency
Greater data integrity and independence from applications programs
Improved data access to users through use of host and query languages
Improved data security
Reduced data entry, storage, and retrieval costs
Facilitated development of new applications program
DBMSCS-7POPULAR PUBLICATIONS
ENTITY-RELATIONSHIP MODEL
Multiple Choice Type Questions
41. Cardinality Ratio means
a) Number attributes associated with an entity
b) Number of Relation of an entity-relationship diagram
c) A ratio between number of relation and number of entity of an entity-
relationship diagram
d) The number of entities to which another entity can be associated via a
relationship set
Answer: (d)
[WeUT 2006, 2008)
2. Overall logical structure of a database can be expressed graphically by
[WBUT 2009, 2016]
a)ERdiagram —_b) Records c) Relations d) Hierarchy
Answer: (a)
3. The information about data in a database is called [WBUT 2009, 2011, 2016]
a) meta data b) tera data c) hyper data d) none of these
Answer: (a)
4. Atable can have only one [WBUT 2010, 2012]
a) Primary key b) Candidate key c) Super key d) all of these
Answer: (a)
5. What is a RDBMS terminology for a set of legal values that an attribute can
have? [WBUT 2010]
a) Tuple b) Relation ¢) Attribute d) Domain
Answer: (d)
6. What is the smallest unit of data in a relational model? [WBUT 2010, 2012]
a) Data type b) Field ¢) Data value d) None of these
Answer: (c) .
7. The word ‘loss’ in lossless refers to [WBUT 2010)
a) loss of information b) loss of attributes
¢) loss of relations d) none of these
Answer: (c)
8. What separates the physical aspects of data storage from the logical aspects of
data representation? [WBUT 2010)
a) Data b) Schema ¢) Constraints d) Relationship
Answer: (b)
DBMSCS-8DATABASE MANAGEMENT SYSTEMS
9. What schema defines how and whore the data are organized in a physical data
storage? (WBUT 2010]
a) External b)Internal —_¢) Conceptual d) None of these
Answer: (c)
10. In ER mode! <~ symbol is used for {WBUT 2012]
a) attribute 6) entity ¢) relation d) none of these
Answer: (a)
11. What is the cardinality of a table with 1000 rows & 10 columns? [WBUT 2012]
a)10 b) 100 c) 1000 d) none of these
Answer: (c)
12. In the relational modes, cardinality is termed as [WBUT 2013, 2019]
a) number of tuples b) number of attributes
c) number of tables d) number of constraints
Answer: (a)
13. The different levels of data abstraction are [WBUT 2015]
a) physical level _b) logical level c) view levet d) all of these
Answer: (4)
14, Which key cannot be null? [WBUT 2016]
a) Unique key b) Primary key c) Super key d) Foreign key
Answer: (b)
15. In the E-R diagram the term ‘Cardinality’ is synonymous to [WBUT 2017]
a) Attribute b) Degree ¢) Entities 4) Cartesian
Answer: (b)
46. It is an abstraction through which relationships are treated as higher level
entities? (WBUT 2018]
a) generalization b) specialization
c) aggregation d) inheritance
Answer: (c)
Short Answer
uestions
4. What is the difference between logical data independence and physical data
independence? [WBUT 2006]
OR,
Define physical data independence and togical dataindependence. [WBUT 2015]
Answer:
Logical data independence: The ability to change the logical (conceptual) schema
without changing the External schema (User View) is called logical data independence.
For example, the addition or removal of new entities, attributes, or relationships to the
DBMSCS-9POPULAR PUBLICATIONS
conceptual schema should be possible without having to change existing external
schemas or having to rewrite existing application programs. The external scheme may
stay unchanged for most changes of the logical scheme. This is especially desirable as the
application software does not need to be modified or newly translated.
Physical data independence: Physical data independence deals with hiding the details of
the storage structure from user applications. The application should not be involved with
these issues, since there is no difference in the operation carried out against the data. The
ability to change the physical schema without changing the logical schema is called
physical data independence. For example, a change to the internal schema, such as using
different file organization or storage structures, storage devices, or indexing strategy,
should be possible without having to change the conceptual or external schemas.
2. Explain the terms Candidate key, Primary key, Foreign key and Super key.
[WBUT 2006, 2017]
oR,
Explain with example super key, candidate key and primary key.
[WBUT 2013, 2019]
OR,
Explain with examples the term super key, candidate key, primary key and
alternate key. [WBUT 2015]
Answer:
Candidate key
In the relational model of databases, acandidate key of arelationis a minimal
superkey for that relation; that is, a set of attributes such that
1. the relation does not have two distinct tuples with the same values for these
attributes (which means that the set of attributes is a superkey)
2. there is no proper subset of these attributes for which (1) holds (which means that
the set is minimal).
Since a relation contains no duplicate tuples, the set of all its attributes is a superkey if
NULL values are not used. It follows that every relation will have at least one candidate
key.
The candidate keys of a relation tell us all the possible ways we can identify its tuples. As
such they are an important concept for the design database schema.
Superkey: A superkey is defined in the relational model of database organization 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 arefunctionally dependent.
Note that if attribute set K is a superkey of relvar R, then at all times it is the case that
the projection of R over K has the same cardinality as R itself.
DBMSCS-10DATABASE MANAGEMENT SYSTEMS
Informally, a superkey is a set df columns within a table whose values can be used to
uniquely identify a row. A candidate key is a minimal set of columns necessary to
identify a row, this is also called a minimal superkey. For example, given an employee
table, consisting of the columns employeeID, name, job, and departmentID, we could use
the employeeID in combination with any or all other columns of this table to uniquely
identify a row in the table. Examples of superkeys in this table would be {employeelD,
Name}, {employeelD, Name, job}, and {employeelD, Name, job, departmentID}.
Foreign key: In the context of relational databases, aforeign keyis a referential
constraint between two tables. The foreign key identifies a column or a set of columns in
cone (referencing) table that refers to a set of columns in another (referenced) table. The
columns in the referencing table must be the primary key or other candidate key in the
referenced table. The values in one row of the referencing columns must occur in a single
row in the referenced table. Thus, a row in the referencing table cannot contain values
that don't exist in the referenced table (except potentially NULL). This way references
can be made to link information together and it is an essential part of database
normalization. Multiple rows in the referencing table may refer to the same row in the
referenced table. Most of the time, it reflects the one (master table, or referenced table) to
many (child table, or referencing table) relationship.
The referencing and referenced table may be the same table, i.e. the foreign key refers
back to the same table. Such a foreign key is known in SQL: 2003 as aself-referencing
or recursive foreign key.
A table may have multiple foreign keys, and each foreign key can have a different
referenced table. Each foreign key is enforced independently by the database system.
‘Therefore, cascading relationships between tables can be established using foreign keys.
Improper foreign key/primary key relationships or not enforcing those relationships are
often the source of many database and data modeling problems.
Primary Key: The primary key of a relational table uniquely identifies each record in the
table. It can either be a normal attribute that is guaranteed to be unique (such as Social
Security Number in a table with no more than one record per person) or it can be
generated by the DBMS (such as a globally unique identifier, or GUID, in Microsoft SQL.
Server). Primary keys may consist of a single attribute or multiple attributes in
combination.
Alternate key: In the candidate key the key which is not primary key is the alternate key.
Example:
CUSTOMER (custno, Name, Address}
ORDERS (Order No, Order Date, custno, part-no, project-no}
Here, the relation CUSTOMER having the key attribute custno, the ORDERS relation
holds the custno as a non key attribute.
‘Thus custno in ORDERS is a foreign key w.r.t CUSTOMER,
DBMSCS-11/PULAR PUBLICATIO!
3. Explain the difference between weak entity set and strong entity set.
Answer:
[WBUT 2006, 2010)
‘Strong entity sets
Weak entity sets
1) An entity set, which has a primary key. is|
termed as strong entity set.
Ty An entity set is called a weak entity set if its|
existence depends on other entities i.e., strong)
entities.
2) A strong entity set have sufficient attributes
to form a primary key.
2) A weak entity.set does not have sufficient
attributes to form a primary key._
3) A strong entity set is indicated in E-R|
| diagram by a singly outlined rectangle.
4) The primary key of strong entity set is formed
by the primary key of the strong entity set.
3) A weak entity set is indicated in E-R
diagrams by a doubly outlined rectangle.
(4) The primary key of weak entity set is formed
iby the primary key of the strong entity 5 set plus}
its discriminator.
4. a) What is metadata?
[WBUT 2007, 2010, 2017]
b) What do you mean by data dictionary? Why is the data dictionary required In
[WBU"
OR,
RDBMS?
What is Data dictionary?
Answer:
T 2007]
[WBUT 2015, 2017, 2019]
a) Metadata is defined as data providing information about one or more other pieces of
data, such as:
= Means of creation of the data
Purpose of the data
Time and date of creation
Creator or author of data
Standards used
Placement on a computer network where the data was created
For example, a digital image may include metadata that describes how large the picture
is, the color depth, the image resolution, when the image was created, and other data. A
text document's metadata may contain information about how long the document is, who
the author is, when the document was written, and a short summary of the document.
Metadata is data. As such, metadata can be stored and managed in a database, often
called a registry or repository. However, it is impossible to identify metadata just by
looking at it because a user would not know
b) Data Dictionary
A data dictionary or metadata repository
about data such as meaning, relationships to
when data is metadata or just data.
is a “centralized repository of information
other data, origin, usage, and format.
A data dictionary is organized into five sections:
Data elements
Data Flows
Data Stores
Processes
External Entities.
DBMSCS-12DATABASE MANAGEMENT S)
The format of the data dictionary contains:
Data Type: Data Element/Data Flow/Data Store
Data Name: Name of the Data Elements, Data Flow/Data Store.
Data Aliases: Altemate names used for the convenience of multiple users.
Data Description: A short description of data.
Data characteristics: Frequency of the use. Data length, Range of data values etc.
Data Composition: Various data elements contained in a data store of data flow.
5. Give an example of derived attribute. [WBUT 2009, 2010]
Answer:
Derived Attribute
The attribute values which are not a part of the entity but can be computed in association
with some other stored attributes.
Derived atmbute
For example the age of a person which can be computed by subtracting the dob from the
current date.
6. Explain candidate key with an example. (WBUT 2011)
Answer:
Refer to Question No. 2 of Short Answer Type Questions.
7. Define super key, candidate key and primary key. [WBUT 2012]
Answer:
Refer to Question No. 2 of Short Answer Type Questions.
8, What is cardinality ratio? [WBUT 2013, 2017]
Answé
Cardinality: Cardinality is the specification of the number of occurrences of one object
that can be related to the number of occurrences of another object.
For example, one object can relate to only one other object (1:1 relationship); one object
can relate to many objects (1:N relationship); Some number of occurrences of an object
can relate to some other number of occurrences of another object (M:N relationship).
Cardinality defines “the maximum number of objects that can participate in a
relationship”. However, it does not provide an indication of whether or not a particular
data object must participate in the relationship. To specify this information, the data
model adds modality to the object/ relationship pair.
9. What is disjointless constraint? [WBUT 2013]
Answer:
Disjoint Constraints: One or more sub collections of a given super collection may be
declared to be disjoint. It implies that no object may occur in more than one of these sub
DBMSCS-13POPULAR PUBLICATIONS
collections. E.g. Employees and Customers may be declared to be disjoint sub collections
of Persons, Such that they can’t be both an employee and a customer.
10. What do you mean by degree, cardinality of relationship? (WBUT 2015)
Answer:
The degree of relationship (also known as cardinality) is the number of occurrences in
one entity which are associated (or linked) to the number of occurrences in another.
There are three degrees of relationship, known as:
1. one-to-one (1:1)
2. one-to-many (1:M)
3. many-to-many (M:N)
11. What do you mean by data abstraction? Explain three levels of data
abstraction? [WBUT 2015]
Answer:
The database Management system provides users an abstract view of data. For users
simplicity DBMS provides different levels of abstraction. The following are different
levels of abstraction.
1. Physical Level
2. Logical Level
3. View Level
Physical Level is the lowest level of abstraction and it defines the storage structure.
Logical Level is the next higher level of abstraction which describes what data are stored
in database, relation between data, types of data etc. View Level is the highest level of
abstraction. It provides different view to different users. At the view level users see a set
of application programs that hide details of data types.
Conceptual Level
‘Data Independence (Logical/Physical)
DBMSCS-14DATABASE MANAGEMENT SYSTEMS
peatinn is Weak entity set? Explain with suitable example. [WBUT 2016}
re
An entity set is called a weak entity set if its existence depends on other entities (called.
strong entities). Thus a weak entity set does not have sufficient attributes to form a
primary key.
As shown in fig. the entity set Departures which has the only attribute date is a weak
entity set. Thi is because of the fact that although each departure entity is distinct,
different flights may have departure on the same day. As a result different flights may
share the same date value, A weak entity set is indicates in E-R diagrams by a doub!;
outlined rectangle. . Y ; en
Fig: E-R diagram for a weak entity set which is dependent on a strong entity set
13. Describe different types of attribute. {WBUT 2017]
Answer:
‘Types of Attribute are:
‘Single valued Attributes: An attribute, that has a single value for a particular entity. For
example, age of a employee entity.
Multi valued Attributes: An attributes that may have multiple values for the same entity.
For example colors of a car entity.
Compound /Composite Attribute: Attribute can be subdivided into two or more other
Attribute. For Example, Name can be divided into First name, Middle name and Last
name.
Stored Attribute: An attribute, which cannot be derived from other attribute, is known as
stored attribute. For example, BirthDate of employee.
Derived Attribute: Attributes derived from other stored attribute. For example age from
Date of Birth and Today’s date.
Key Attribute: represents primary key. (main characteristics of an entity), It is an
attribute, that has distinct value for each entity/element in an entity set. For example, Roll
number in a Student Entity Type.
explain,
14, “Primary keys are candidate keys but reverse is not true.”
; [WBUT 2018}
DBMSCS-15:POPULAR PUBLICATIONS
Answer:
Super Key: An attribute or set of attributes that uniquely identifies a tuple within a
relation
Candidate key: A super key such that no proper subset is a super key within the relation
Primary key: The candidate key that is selected to identify tuples uniquely within the
relation, the candidate keys which are not selected as PKs are called "Alternate keys". So
the reverse is Alternate keys.
45. Explain with example the difference between strong and weak entity sets.
{WBUT 2019)
Answer: Refer to Question No. 3 (I Part) of Short Answer Type Questions.
Example of Strong entity set & Weak entity set:
EIErO Emo)
some) Gomis)
Flight is a strong entity.
Departures is a weak entity.
1. Design a Generalization-Specialization hierarchy for a motor-vehicle sales
company. The company sells motor-cycles, passenger cars, vans, buses. Justify
vu placement of attributes at each level of the hierarchy. [WBUT 2010, 2011)
nswer:
The generalization-specialization hierarchy for the motor-vehicle company is given ‘in
the figure. model, sales-tax-rate and sales-volume are auributes necessary for all types of
vehicles. Commercial vehicles attract commercial vehicle tax, and each kind of
commercial vehicle has a passenger carrying capacity specified for it. Some kinds of non-
commercial vehicles attract luxury vehicle tax. Cars alone can be of several types, such as
sports-car, sedan, wagon etc. hence the attribute type.
DBMSCS-16.vehicle
2. a) What do you mean by composite attribute and derived attribute? Give
example. [WBUT 2014]
Answer:
Composite eT Th
sweet stirs Hse Number Zp,
LN.
Composite Attribute
Can be divided into smaller subparts, which contains independent meaning. The address
attribute of the employee relation can be divided into House Number, Street Address,
City, State and zip.
Derived Attribute:
The attribute values which are not a part of the entity but can be computed in association
with some other stored attributes. It is not stored but can be computed as required.
For example the age of a person which can be computed by subtracting the dob from the
current date.
DBMSCS-17Put UBLICATIONS
b) Some of the entries relevant to a technical university are given bellow:
For each of them, indicate the type of relationship existing among them (for
example, one-to-one, one-to-many or many to many). Draw a relationship diagram
for each of them.
i) STUDENT and ENGG-BRANCH (students register for engg branches)
ii) BOOK and BOOK-COPY (books have copies)
iil) ENGG-BRANCH and SECTION (branches have section)
iv) SECTION and CLASS-ROOM (sections are scheduled in classrocirs)
v) FACULTY and ENGG-BRANCH (faculty teaches in a particular branch)
(WBUT 2011)
Answer:
i 1 1
i :
-. 1 a
ii
) [Bock > Book Copies
iil) ' ‘
Eng Branch Section
| 1 1
iv) | section Class Rooms,
1 1
y) | Facuty Eng Branch
¢) An E-R diagram can be viewed as a graph. What do the following means in terms
of the structure of an enterprise schema? [WBUT 2011]
i) The graph is disconnected
ii) The graph is cyclic.
Answer:
i) If pair of entity sets is connected by a path in an E-R diagram, the entity sets are
related. A disconnected graph implies that there are pairs of entity sets that are unrelated
to each other. If we split the graph into connected components, we have, in effect, a
separate database corresponding to each connected component. At this point analogy is
with partial and complete participation with E-R diagram,
ii) A path in the graph between a pair of entity sets indicates an indirect relationship
between the two entity sets. If there is a cycle in the graph then every pair of entity sets
on the cycle are related to each other at least in two distinct ways. If the E-R diagram is
DBMSCS-18DATABASE MANAGEMENT SYSTEMS
acyclic then there is a unique path between every pair of entity sets and a unique
relationship between every pair of entity sets and is a total participation only.
3. a) What Is multiple inheritance? {wBuT 2012]
b) What is attribute inheritance?
¢) Draw ER diagram showing cardinality:
|) A bill is sent to a customer. A customer may receive may receive many bills.
li) A clerk works in a bank. A bank has many clerks.
lii) Students appear for seats in college. Each student can get almost one seat. A
college has many seats. A student can sent many applications.
d) With an example describe specialization and generalization.
Answer: t
a) The best way to answer this question is to look at each relationship that is possible
between tables (or entities). There are three. The one to one, one to many and many to
many.
One to one is easy. For example, one person can only have one social security number
(SIN in US). So one table contains the name of the person and another table contains the
SSN.
One to many - Here again we compare two values, each in separate tables. For example
one teacher has many students.
Many to many - There's a simple way to look at this. Let's take our example from above.
One teacher has many students, But isn't it also the case that one student has many
teachers? So if we have two tables, one showing all the information about teachers and
the other showing all the information about students. If we connect the table thus —
Teacher - 1 0 many ~ Student
Then look at it from the other direction
Teacher - many 0 | — Student
But really the relationship is - Teacher - many 00 many - Student
b) The higher and lower level entities created by specialization and generalization is
attribute inheritance. The lower levet entities are inherited from the higher level
entities. For example, the entities project-member and the entities Project-manager are
inherited form the entity person.
NS tHe Ae
Vor more many
i) A bill is sent to a customer, A customer may receive many bills.
me <>< aa]
DBMSCS-19POPULAR PUBLICATIONS
ii) A clerk works in a blank. The bank has many clerks.
CLERK <
iii) Students appear for seats in collage. Each student can get almost one seat. A college
has many seats. A student can sent many applications.
STUDENT
4) Specialization is opposite to Generalization. It is a top-down approach in which one
higher level entity can be broken down into two lower level entity. In specialization,
some higher level entities may not have lower-level entity sets at all.
Current Student
Generalization is a bottom-up approach in which two lower level entities combine to
form a higher level entity. In generalization, the higher level entity can also combine with
other lower level entity to make further higher level entity.
DBMSCS-20DATABASE MANAGEMENT SYSTE!
4. a) Draw an ER diagram for the system given as follows:
An organization has number of faculties who are expert in one or more subjects.
For each subject, number of such experts is there, system will store faculty and
subject information and must support query on finding expertise on subjects.
Students get enrolled to have training on one or more subjects. System will keep
student information also. One fac: is allotted to teach one or more subjects and
for one subject only one faculty is assigned. System will keep the information
regarding such assignment. [WBUT 2014, 2019]
b) Describe how the entity animal (in a ZOO) can be developed into a specialization
hierarchy. [WBUT 2014]
c) What is meant by a recursive relationship type? Give one example of recursive
relationship type. [WBUT 2014]
Answer:
a)
»)
‘Amphibians
D of antmal in a 200 a specialization hierarchy
DBMSCS-21POPULAR PUBLICATIONS
c) A recursive relationship type exists if an entity can be related to itself or in other
words, the same entity type participates more than once in a relationship type in different
roles. An example of a recursive relationship type is courses that require one or more
other courses as prerequisites. The course entity is related to another course entity. In this
case, the recursive relationship “course is a prerequisite to course” also happens to be a
Mw relationship. This is because a course can have more than one prerequisite, and a
course can be a prerequisite to many other courses.
Another example ofa recursive relationship type is in a supervision relationship -type
between an employee and a supervisor. Both entities are members of the same Employee
entity type. In this example, the employee entity type participates twice in the supervision
relationships, once in the role of a supervisor, and once in the role of supervisee.
5. Supreme products manufacture products like pressure cookers, cook wares,
water purifiers, food processors etc. The company markets its product to
wholesalers all over the country and dealers sell them to customer. The company
has five regional offices. Sales persons contact dealers and explain about
products, incentives offered, panting programs for wholesalers and demonstration
for customer etc. Dealers place orders with the sales persons attached with the
regional office of their location. After receiving goods they make payments, which
may be in installments. Company would like to develop a system to monitor sale of
different products, performance of salespersons and order from wholesalers. Do
the following:
i) Identify entities, attributes and relationship.
ii) Draw an E-R diagram.
iil) Convert this to relational tables. IWBUT 2015]
Answer:
i) and ili) Relational Tabies with attributes, primary keys (underlined), foreign keys are
marked as (FK)
Company {companyid. companyname, Prodid, phone,fax, address,License}
Product{prodid, companyid(fk),prodname, capacity, Manufacturedate, inspectiondate}
Marketer{Markererid. type, location, contactdetails, phone, prodid(tk)}
Order {orderid, Marketerid(fk), Regionalofficeid, location, prodid, custid(Fk), orderdate}
Customer {Custid, cusiname, prodid|,prodid2, prodid3, prodid4, phone, fax}
Payment {paymentid, date. mode,ordered, marketerid, prodid, amount, remarks}
DBMSCS-22‘AB. AGEMENT)
ii) E-R diagram
6. Draw the ER diagram of a hospital management system and explain.
[WBUT 2016]
Answer:
Patrotosy
ENT
7. What is mapping constraint? Describe three-layer architecture of DBMS.
(WBUT 2019)
Answer:
IPart:
Mapping Constraint:
A mapping constraint is a data constraint that expresses the number of entitles to Which
another entity can be related via’ a relationship set. It is most useful in describing the
relationship sets that involve more than two entity sets.
. DBMSCS-23ULAR PU! iS
There are four possible mapping cardinalities. These are as follow:
1. One to one (1 : 1)
2. One to many (1 : M)
3. Many to one (M : 1)
4. Many to many (M : M)
One to one (1: 1):
Let, entity El, E2 and R is relation.
BRS
Let, entity El, E2 and R is relation.
Many to one (M: 1):
Let, entity El, E2 and R is relation.
Many to many (M: M)
Let, entity El, E2 and R is relation.
Kee]
2™ Part: Refer to Question No. 1 of Short Answer Type Questions.
8. Write short note on Data Dictionary. [WBUT 2013]
Answer:
Refer to Question No. 4(b) of Short Answer Type Questions,
DBMSCS-24DATABASE MANAGEMENT SYSTEMS
RELATIONAL MODEL
Multiple Choice Type Questions
1. Relational algebra is a [WBUT 2007, 2019]
a) procedural language b) non-procedural language
¢) query language d) normalization technique
Answer: (a)
2. Relational calculus is a
(WBUT 2013]
a) procedural language b) non-procedural language
c) data definition language 4) high level language
Answer: (b)
3. Cartesian product in relational algebra is ([WBUT 2013, 2019)
a) a unary operator b) a binary operator
¢) a ternary operator d) not defined
Answer: (a)
4. In a relational model, relations are termed as [WBUT 2013}
a) tuples b) attributes c) tables d) rows
Answer: (c)
5. In case of entity integrity, the primary key may be [WBUT 2013)
a) not Null b) Null c) both Null & not Null d) any value
Answer: (a)
6. In an E-R diagram an entity set is represented by a [WBUT 2013]
a) rectangle b) ellipse c) diamond box d) circle
Answer: (2)
7. Using relational algebra the query that finds customers, who have a balance of
over 1000 is . {WBUT 2013)
a) Customer_name(o balance > 1000 (Deposit))
b) cCustomer_name(balance > 1000 (Deposit))
¢) Customer_name(¢ balance > 1000 (Borrow)
d) eCustomer_name(balance > 1000 (Borrow)
Answer: (a)
8. Which of the following operations is used if we are interested in only certain
columns of a table? [WBUT 2013, 2019)
a) PROJECTION b) SELECTION c) UNION d) JOIN
Answer: (a)
DBMSCS-25JBLICATIOI
9. The strategy for processing a query Is improved by [WBUT 2015, 2019)
a) query evaluation b) decomposition
¢) query optimization d) none of these
Answer: (c)
10. Relational calculus is a (WBUT 2016]
a) Query language b) procedural language
c) Non-procedural language d) None of these
Answer: (a)
11. A row from a table is selected by [WBUT 2016]
a) selection operator b) projection operator
¢) union operator d) none of these
Answer: (a)
12. According to the levels of abstractions the schema at the intermediate level is
called [WBUT 2018}
a) logical schema b) physical schema
c) subschema 4) super schema
Answer: (a)
13. The operation which is not considered as basic operation in relational algebra
[WBUT 2018]
a) join b) selections c) union d) cross product
Answer: (a)
Short Answer estions
4. Why we need query optimization? [WBUT 2008]
Answer:
Having long-running queries not only consumes system resources that makes the server
and application run slowly, but also may lead to table locking and data corruption issues.
So, query optimization (QO) becomes an important task. As there are many equivalent
transformations of same high-level query, aim of QO is to choose one that minimizes
resource usage. In general it also reduces total execution time of query. Since the problem
is computationally intractable with large number of relations, so strategy adopted is
reduced to finding near optimum solution. .
2. Discuss the entity integrity and referential integrity constraints. Why is each
Considered important? Explain with suitable example. —_ [WBUT 2008, 2010, 2012)
Answer:
Entity Integrity: \n a relational database, enti
records are duplicated and that no attributes tI
one of the properties necessary to ensure the
Entity Integrity ensures that there are no di
field that identities each record within the
ity integrity is a Property that ensures that no
that make up the primary key are NULL. It is
consistency of the database.
uplicate Tecords within the table and that the
table is unique and never null. The existence of
DBMSCS-26DATABASE, \GEMENT |
the Primary Key is the core of the entity integrity. If one defines a primary key for each
entity, they follow the entity integrity rule. Entity integrity specifies that the Primary
Keys on every instance of an entity must be kept, must be unique and must have values
other than NULL, Entity Integrity is the mechanism the system provides to maintain
primary keys. The primary key serves as a unique identifier for rows in the table.
‘The system enforces Entity Integrity by not allowing operations (INSERT, UPDATE) to
produce an invalid primary key. Any operation that creates a duplicate primary key or
one containing nulls is rejected.
Referential Integrity: \t is a database management safeguard that ensures every foreign
key matches a primary key. For example, customer numbers in a customer file are the
primary keys, and customer numbers in the order file are the foreign keys. If a customer
record is deleted, the order records must also be deleted; otherwise they are left without a
primary reference. If the DBMS does not test for this, it must be programmed into the
applications.
Referential integrity in a relational database is consistency between coupled tables.
Referential integrity is usually enforced by the combination of a primary key(candidate
key) and a foreign key. For referential integrity to hold, any field in a table that is
declared a foreign key can contain only values from a parent table's primary key or a
candidate key. For instance, deleting a record that contains a value referred to by a
foreign key in another table would break referential integrity. The RDBMS enforces
referential integrity, normally either by deleting the foreign key rows as well to maintain
integrity, or by retuming an error and not performing the delete. Which method is used
would be defined by the definition of the referential integrity constraint.
Example: An employee database stores the department in which each employee works.
The field "DepartmentNumber” in the Employee table is declared a foreign key, and it
refers to the field "Index" in the Department table which is declared a primary key
Referential integrity would be broken by deleting a department from the Department
table if employees listed in the Employee table are listed as working for that department,
unless those employees are moved to a different department at the same time.
3. Why are entity integrity and referentiqgl integrity important in a database?
[WBUT 2009, 2011)
Answer:
Refer to Question No, 2(1" Part) of Short Answer Type Questions.
4. consider the following “sailors” and “reserves” relations: © [WBUT 2012, 2014)
R (sid. bid, day)
S (sid, sname, rating, age)
Formulate the following queries using relational algebra”
a) Find names of sailors who have reserved boat # XXX.
b) Find names and ages of sailors who have reserved a boat
DBMSCS-27LAR PUBLICATIONS
Answer:
A) Tsnane (Gs sis =n sia (SX R)).
D) Mename . age (Bs sid = R sia (SX R)).
5. a) What is the disadvantage of Cartesian product and how to recover from it?
Answer:
The Cartesian product, is referred to as a cross-join, returns all the rows in all the tables
listed in the query. Each row in the first table is paired with all the rows in the second
table. This happens when there is no relationship defined between the two tables. Say
AUTHOR and STORE tables have ten rows each. If we use a Cartesian join in these two
tables, we get 100 rows.
To get rid of this problem, most of the time, we provide a filter on the join. If we actually
want a cartesian join, then we should use the ANSI cross join to tell others reading the
script that we actually wanted a Cartesian join.
b) Explain full outer join, left outer join, right outer join with examples.
Answer:
Before we proceed lets consider the table Company and Department
1 | IT Billing
2 | Engineering
3 | Finance
The LEFT OUTER JOIN
The OUTER JOIN is an extension of the INNER JOIN. SQL standard defines three types
of OUTER JOINs: LEFT, RIGHT, and FULL and PostgreSQL supports all of these.
performed first. Then, for each row in
table T1 that does not satisfy the join condition with any row in table T2, a joined row is
In case of LEFT OUTER JOIN, an inner join i:
DBMSCS-28
| address | salary | join_date
aS oman ane, + a
| California] 20000 | 2001-07-13
| Norway | 20000 |
| Rich-Mona | 65000 | 2007-12-13
| Texas | 85000 "| 2007-12-13
| Texas | | 2007-12-13
| Houston | 20000 | 2005-07-13
| Norway | 5000 | 2005-07-13
| Texas | 5000 | 2005-07-13
”BASE.
added with null values in col
( lumns of T2. Thus, the joined table always has at least one
row for each row in TI,
Following is the syntax of LEFT OUTER JOIN:
SELECT ... FROM tablel LEFT OUTER JOIN table2 oN
conditional_expression ...
Based on the above tables, we can write a inner join as follows:
testdb=# SELECT EMP_ID, NAME, DEPT FROM COMPANY LEFT OUTER JOIN
DEPARTMENT
ON COMPANY.ID = DEPARTMENT. EMP_ID;
Above query will produce the following result:
emp_id | name | dept
IT Billing
Engineering
The RIGHT OUTER JOIN
First, an inner join is performed. Then, for each row in table T2 that does not satisfy the
join condition with any row in table Tl, a joined row is added with null values in
columns of T1. This is the converse of a left join; the result table will always have a row
for each row in T2.
Following is the syntax of LEFT OUTER JOIN:
SELECT ... FROM tablel RIGHT OUTER JOIN table2 ON
conditional_expression ...
Based on the above tables, we can write a inner join as follows:
testdb=# SELECT EMP_ID, NAME, DEPT FROM COMPANY RIGHT OUTER JOIN
DEPARTMENT
ON COMPANY. ID = DEPARTMENT. EMP_ID;
Above query will produce the following result:
emp_id | name | dept
1 | Paul | IT Billing
2 | Allen | Engineering
71 | Finance
The FULL OUTER JOIN
DBMSCS-29POPULAR PUBLICATIONS
First, an inner join is performed. Then, for each row in table T1 that does not satisfy the
join condition with any row in table T2, a joined row is added with null values in
columns of T2. Also, for each row of T2 that does not satisfy the join condition with any
row in T1, a joined row with null values in the columns of T1 is added.
Following is the syntax of FULL OUTER JOIN:
SELECT ... FROM tablel FULL OUTER JOIN table2 ON
conditional_expression ...
Based on the above tables, we can write a inner join as follows:
testdb=# SELECT EMP_ID, NAME, DEPT FROM COMPANY FULL OUTER JOIN
DEPARTMENT
ON COMPANY.ID = DEPARTMENT. EMP_ID;
Above query will produce the following result:
emp_id | name | dept
Paul | IT Billing
Engineering
Finance
|
!
|
Davia |
|
1
6. What do you mean by unary and binary operations in Relational algebra? Give
example. (WBUT 2015, 2016]
Answer:
Unary operator (one relation as operand)
Returns subset of the tuples from a relation that satisfies a selection condition:
oR
RENAME operator
Rename relation pSR
Binary Relational Operations: JOIN and DIVISION
R vaS
where join condition is a Boolean expression involvin;
relations
R=S
Attributes of S must be a subset of the attributes of R
attr(R = S) = attr(R) — attr(S)
ttuple in (R= S) iff (1 « S) is a subset of R
ig attributes from both operand
DBMSCS-30For example:
P:
A_[B
at_|bi
al b2_]-
a2_ | bl
a3 | bI
a4 | b2
aS | bl
a5 | b2
3 P+Q3=
[A _|
7. Consider the following database with primary keys underlined
Project (P_—No, P — Name, P —incharge)
Employee (E —no, E - Name)
Assigned-To (E — no, P— no)
Write relational algebra expression for the following:
(a) List detail of employee working on all projects.
(b) List E — no, E — name of employee who do not work on project with P - no =
DB2003. (WBUT 2018)
Answer:
a) K=n eno, e-nanep-no( Employee Dj Assigned-To)
8
E-no
Teno, € -Nene,?~ na P-Name (Project ><] K)
e
P-no
b) K=m p- po.e-Nane,p-w- (Employee D<] Assigned—To)
8
E-10
Teno, E- Name P -no, P-Naneo GF P-roo' poxoas (Project >I K)
8
P-no
8. What is referential integrity? [WBUT 2019)
Answer:
Refer to Question No. 2 (1" Part) of Short Answer Type Questions.
DBMSCS-31UBLICATIONS
9. Define the following: [MODEL QUESTION]
i) Derived attribute
ii) Domain
iii) 1 to Many relationship
iv) Projection
v) Union compatibility
Answer:
i) Derived Attribute: . -
The attribute values which are not a part of the entity but can be computed in association
with some other stored attributes. It is not stored but can be computed as required.
ed attribute
For example the age of a person which can be computed by subtracting the dob from the
current date.
ii) Domain:
Each simple attribute of an entity type is associated with a value set, which specifies the
Set of values that may be assigned to that attribute for each individual entity.
©.g., If the range of ages allowed for employees is between 16 to 70. We can say that the
domain of age attribute in employee table is (16-70).
iii) One-to-many:
1: M, exists when one occurrence of the
the second entity, but each occurren
one occurrence of the first entity.
e first entity can be related to many occurrences of
ice of the second entity can be associated with only
iv) Projection Operator: The Projection operation
selective attributes from a relation. It is a vertic:
operation is symbolized by m.
The syntax of the projection query is:
Projects all or an attribute or a set of
al subset of the given relation. The
Tstistor atinbete names offset postion> (Relation Name)
For example, let us execute the following queries using the relation Employee
Find the employees whose EMP# is greater than 100 and less than 104 and Working
under the manager Patel-and show all the attributes
~ Tempe Name Det Mose tnp109 + np tMnagrPoa: (EMPLOYEE)
¥) The operations union, difference, intersection are union compatible. Any two relations
A and B are said to be union compatible if A and B are of the same degree say ‘n ‘and the
domain of the corresponding n attributes are identical,
Leif A=A{ay,a,,.......,a,} and
DBMSCs-32DATABASE MANAGEMENT SYSTEMS.
B=B{bj,b3,.........0,) then Dom(A)=Dom(B) for {i=1,2,3,.....n}, where Dom(A; )
represents the domain of the attribute A; .
1. Union-compatible relation:
R=AU B stR={t|te A Vte B}
2. Difference:
R=A-B st.R=(t]teAAt® B}
3. Intersection:
R=ANB stR={t/teAAte B}
4. Cartesian Product:
R=A xBs.t R={tl [|(2|tleA At2 eB}
Difference and Intersection are childsets of union, thus on operations upon a table must
be union compatible.
Relational Algebra is Complete:
The set of relational algebra operators {o,2,U,-,x} is a complete set. Any other
relational algebra operations can be expressed as a sequence of operations from this set.
Let us see the equivalent expression of intersection is,
RAS=RUS-(R-S)u (S - R))
10. Explain how a relational calculus expression can be unsafe. Illustrate your
answer with an example. [MODEL QUESTION]
Answer:
1. A tuple relational calculus expression may generate an infinite expression, e.g.
{t|= (te Student)}
2. There are an infinite number of tuples that are not in student. Most of these tuples
contain values that don’t appear in the database.
Safe Tuple Expressions: The relational calculus domain of a formula P, denoted dom (P),
is the set of all values referenced in P.
These include values mentioned in P as well as values that appear in a tuple of a relation
mentioned in P. So, the domain of P is the set of all values explicitly appearing in P or
that appear in relations mentioned in P.
dom(t borrows t{ amount] < 1200) is the set of all values appearing in borrow.
dom(t|-(t €borrow)) is the set of all values appearing in borrow.
We may say an expression {#|P(s)} is safe if all values that appear in the result are
values from dom(P). A safe expression yields a finite number of tuples as its result.
Otherwise, it is called unsafe.
DBMSCS-33