Sie sind auf Seite 1von 11

ADITYA COLLEGE OF ENGINEERING

PUNGANUR ROAD, MADANAPALLE-517325


II-B.Tech(R13) II-Sem I-Internal Examinations Sep-2016 (Descriptive)
13A05301 Database Management Systems ( CSE )
Time: 90 min

Max Marks: 30

Answer all the questions

3 10 =30 M

1. (a) What are the various levels of abstraction?


Ans.

The man purpose of DBMS is to provide users with an abstract view of the data.
The data abstraction is in three levels.
Physical level: How the data are actually stored that means what data structures are used to
store data on Hard disk.
Ex: Sequential , Tree structured
Logical Level or Conceptual Level : What data are stored in database
View level or External Level : It is the part of data base which usually are also in terms of
the data model of the DBMS, allow data access to be customized (and authorized) at the level
of individual users or groups of users.
Ex: Required records in table.
Any given database has exactly one conceptual schema and one physical schema because it
has just one set of stored relations, but it may have several external schemas, each tailored to
a particular group of users. Each external schema consists of a collection of one or more
views and relations from the conceptual schema.
List any four advantages of Databases.
Ans The Main advantages of DBMS are described below.
Controlling Data Redundancy
In non-database systems each application program has its own private files. In this case, the
duplicated copies of the same data is created in many places. In DBMS, all data of an
organization is integrated into a single database file. The data is recorded in only one place in
the database and it is not duplicated.
Sharing of Data
In DBMS, data can be shared by authorized users of the organization. The database
administrator manages the data and gives rights to users to access the data. Many users can be
authorized to access the same piece of information simultaneously. The remote users can also

share same data. Similarly, the data of same database can be shared between different
application programs.
Data Consistency
By controlling the data redundancy, the data consistency is obtained. If a data item appears
only once, any update to its value has to be performed only once and the updated value is
immediately available to all users. If the DBMS has controlled redundancy, the database
system enforces consistency.
Integration of Data
In Database management system, data in database is stored in tables. A single database
contains multiple tables and relationships can be created between tables (or associated data
entities). This makes easy to retrieve and update data.
Integration Constraints
Integrity constraints or consistency rules can be applied to database so that the correct data
can be entered into database. The constraints may be applied to data item within a single
record or the may be applied to relationships between records.
Data Security
Form is very important object of DBMS. You can create forms very easily and quickly in
DBMS. Once a form is created, it can be used many times and it can be modified very easily.
The created forms are also saved along with database and behave like a software component.
A form provides very easy way (user-friendly) to enter data into database, edit data and
display data from database. The non-technical users can also perform various operations on
database through forms without going into technical details of a fatabase.
Report Writers
Most of the DBMSs provide the report writer tools used to create reports. The users can create
very easily and quickly. Once a report is created, it can be used may times and it can be
modified very easily. The created reports are also saved along with database and behave like a
software component.
Control Over Concurrency
In a computer file-based system, if two users are allowed to access data simultaneously, it is
possible that they will interfere with each other. For example, if both users attempt to perform
update operation on the same record, then one may overwrite the values recorded by the
other. Most database management systems have sub-systems to control the concurrency so
that transactions are always recorded with accuracy.
Backup and Recovery Procedures
In a computer file-based system, the user creates the backup of data regularly to protect the
valuable data from damage due to failures to the computer system or application program. It
is very time consuming method, if amount of data is large. Most of the DBMSs provide the
'backup and recovery' sub-systems that automatically create the backup of data and restore
data if required.
Data Independence
The separation of data structure of database from the application program that uses the data is
called data independence. In DBMS, you can easily change the structure of database without
modifying the application program.

(c) Write a short note on Buffer Manager.


In terms of the DBMS architecture the buffer manager is the software layer that is responsible
for bringing pages from disk to main memory as needed. The buffer manager manages the
available main memory by partitioning it into a collection of pages, which we collectively
refer to as, the buffer pool. The main memory pages in the buffer pool are called frames. It is
convenient to think of them as slots that can hold a page ( that usually resides disk or other
secondary storage media). Checks the buffer pool to see if it contains the requested page. If
the page is not in the pool, the buffer manager brings it in as follows:
Chooses a frame for replacement, using the replacement policy

If the dirty bit for the replacement frame is on, writes the page it contains to disk ( that is,
the disk copy of the page is overwritten with the concents of the frame).
Reads the requested page into the replacement frame.
Buffer replacement policies :
Least recently used
Clock replacement
(i) Least Recently used :
The best known replacement policy is least recently used (LRU). This can be implemented in
the buffer manager using a queue of pointers to frames with pin-count 0. A frame is added to
the end of the queue when it becomes a candidate for replacem ent ( that is, when the pincount goes to 0). The page chosen for replacement is the one in the frame at the head of the
queue.
(ii) Clock Policy :
A variant of LRU, called clock replacement, has similar behaviour but less over head.
Other replacement policies include first in first out (FIF)) and most recently used (MRU)
which also entail overhead similar to LRU, and random, among others.
(d) Explain about physical data independence and logical data independence.
The ability to modify schema definition in one level with affecting a schema definition in the next
higher level is called data independence.
Physical independence
All the schemas are logical, and the actual data is stored in bit format on the disk. Physical data
independence is the power to change the physical data without impacting the schema or logical data.
For example, in case we want to change or upgrade the storage system itself suppose we want to
replace hard-disks with SSD it should not have any impact on the logical data or schemas.
Logical independence
Logical data is data about database, that is, it stores information about how data is managed inside.
For example, a table (relation) stored in the database and all its constraints, applied on that relation.
Logical data independence is a kind of mechanism, which liberalizes itself from actual data stored on
the disk. If we do some changes on table format, it should not change the data residing on the disk.
(e) Explain types of attributes in E/R with an example.
Entities are represented by means of their properties, called attributes. All attributes have values. For
example, a student entity may have name, class, and age as attributes.
There exists a domain or range of values that can be assigned to attributes. For example, a student's
name cannot be a numeric value. It has to be alphabetic. A student's age cannot be negative, etc.
Types of Attributes
Simple attribute Simple attributes are atomic values, which cannot be divided further. For example,
a student's phone number is an atomic value of 10 digits.
Composite attribute Composite attributes are made of more than one simple attribute. For example,
a student's complete name may have first_name and last_name.
Derived attribute Derived attributes are the attributes that do not exist in the physical database, but
their values are derived from other attributes present in the database. For example, average_salary in a
department should not be saved directly in the database, instead it can be derived. For another
example, age can be derived from data_of_birth.
Single-value attribute Single-value attributes contain single value. For example
Social_Security_Number.
Multi-value attribute Multi-value attributes may contain more than one values. For example, a
person can have more than one phone number, email_address, etc.

2. (a) Distinguish between Traditional File processing and DBMS.


FILE SYSTEM
A File System is a collection of raw data files stored
in the hard-drive.

A File System is one of the earliest ways of managing


data.

DBMS
A DBMS is a bundle of applications that is dedicated
for managing data stored in databases. It is the
integrated system used for managing digital
databases, which allows the storage of database
content, creation/ maintenance of data, search and
other functionalities.
A dbms is one of the latest ways of managing data.

In a File System, most tasks such as storage, retrieval


and search are done manually and it is quite tedious

A DBMS will provide automated methods to


complete these tasks.

File System will lead to problems like data integrity,


data inconsistency and data security

But these problems could be avoided by using a


DBMS

A file-processing system coordinates only the


physical access.

A database management system coordinates both


the physical and the logical access to the data

The data written by one program in a file-processing


system may not be readable by another program.

A database management system reduces the


amount of data duplication by ensuring that a
physical piece of data is available to all programs
authorized to have access to it

A file-processing system is designed to allow


predetermined access to data (i.e., compiled
programs)

A database management system is designed to allow


flexible access to data (i.e., queries)

A file-processing system is usually designed to allow


one or more programs to access different data files
at the same time. In a file-processing system, a file
can be accessed by two programs concurrently only
if both programs have read-only access to the file.

A database management system is designed to


coordinate multiple users accessing the same data at
the same time.

Redundancy is not control in file system


When data is lost in file system then it can not
recover on its own.
Data is isolated in file system,
Unauthorized access is not restricted in File System

Redundancy is control in DBMS


DBMS provide back up and recovery.
DBMS provide multiple user interfaces.
Unauthorized access is restricted in DBMS

(b) Explain the Architecture of DBMS in brief?


The DBMS accepts SQL commands generated from a variety of user interfaces, produces
query evaluation plans, executes these plans against the database, and returns the answers.
When a user issues a query, the parsed query is presented to a query optimizer which uses
information about how the data is stored to produce an efficient execution plan for evaluating
the query. An execution plan is a blueprint for evaluating a query, and is usually represented
as a tree of relational operators Relational operators serve as the building blocks for
valuating queries posed against the data.The code that implements relational operators sits on
top of the file and access methods layer. This layer includes a variety of software for
supporting the concept of a file, which, in a DBMS, is a collection of pages or a collection of
records. This layer typically supports a heap file, or file of unordered pages, as well as
indexes. In addition to keeping track of the pages in a file, this layer organizes the
information within a page. The files and access methods layer code sits on top of the buffer
manager, which brings pages in from disk to main memory as needed in response to read
requests. The lowest layer of the DBMS software deals with management of space on disk,
where the data is stored. Higher layers allocate, deallocate, read, and write pages through
(routines provided by) this layer, called the disk space manager. The DBMS supports
concurrency and crash recovery by carefully scheduling user requests and maintaining a log

of all changes to the database. DBMS components associated with concurrency control and
recovery include the transaction manager, which ensures that transactions request and release
locks according to a suitable locking protocol and schedules the execution transactions; the
lock manager, which keeps track of requests for locks and grants locks on database objects
when they become available; and the recovery manager, which is responsible for maintaining
a log, and restoring the system to a consistent state after a crash.

3. (a) Explain various data models.


Data models:
A Database model defines the logical design of data. Underlying the structure of a data base is the
data model. The collection of conceptual tools for describing data, data relationships, data semantics.
Three types of data models are there:
Hierarchical Model
Network Model
Relational Model

Hierarchical Model
In this model each entity has only one parent but can have several children . At the top of
hierarchy there is only one entity which is called Root.

Network Model
In the network model, entities are organised in a graph,in which some entities can be
accessed through several path

Relational Model
In this model, data is organised in two-dimesional tables called relations. The tables or
relation are related to each other.

(b) Explain about Extended features of E/R.


The ER Model has the power of expressing database entities in a conceptual hierarchical manner. As
the hierarchy goes up, it generalizes the view of entities, and as we go deep in the hierarchy, it gives us
the detail of every entity included.
Going up in this structure is called generalization, where entities are clubbed together to represent a
more generalized view. For example, a particular student named Mira can be generalized along with all

the students. The entity shall be a student, and further, the student is a person. The reverse is called
specialization where a person is a student, and that student is Mira.
Generalization
As mentioned above, the process of generalizing entities, where the generalized entities contain the
properties of all the generalized entities, is called generalization. In generalization, a number of entities
are brought together into one generalized entity based on their similar characteristics. For example,
pigeon, house sparrow, crow and dove can all be generalized as Birds.

Specialization
Specialization is the opposite of generalization. In specialization, a group of entities is divided into subgroups based on their characteristics. Take a group Person for example. A person has name, date of
birth, gender, etc. These properties are common in all persons, human beings. But in a company, persons
can be identified as employee, employer, customer, or vendor, based on what role they play in the
company.

Similarly, in a school database, persons can be specialized as teacher, student, or a staff, based on what
role they play in school as entities.
Inheritance
We use all the above features of ER-Model in order to create classes of objects in object-oriented
programming. The details of entities are generally hidden from the user; this process known as
abstraction. Inheritance is an important feature of Generalization and Specialization. It allows lowerlevel entities to inherit the attributes of higher-level entities.

For example, the attributes of a Person class such as name, age, and gender can be inherited by lowerlevel entities such as Student or Teacher.

4. (a) Explain about Relational data model.


Relational data model is the primary data model, which is used widely around the world for data storage
and processing. This model is simple and it has all the properties and capabilities required to process
data with storage efficiency.

Tables In relational data model, relations are saved in the format of Tables. This format stores the
relation among entities. A table has rows and columns, where rows represents records and columns
represent the attributes.
Tuple A single row of a table, which contains a single record for that relation is called a tuple.
Relation instance A finite set of tuples in the relational database system represents relation instance.
Relation instances do not have duplicate tuples.
Relation schema A relation schema describes the relation name (table name), attributes, and their
names.
Relation key Each row has one or more attributes, known as relation key, which can identify the row
in the relation (table) uniquely.
Attribute domain Every attribute has some pre-defined value scope, known as attribute domain.

(b) Explain various integrity Constraints in detail.


Every relation has some conditions that must hold for it to be a valid relation. These conditions are
called Relational Integrity Constraints. There are three main integrity constraints

Key constraints
Domain constraints
Referential integrity constraints

Key Constraints
There must be at least one minimal subset of attributes in the relation, which can identify a tuple
uniquely. This minimal subset of attributes is called key for that relation. If there are more than one
such minimal subsets, these are called candidate keys.
Key constraints force that
in a relation with a key attribute, no two tuples can have identical values for key attributes.
a key attribute can not have NULL values.
Key constraints are also referred to as Entity Constraints.
Domain Constraints
Attributes have specific values in real-world scenario. For example, age can only be a positive integer.
The same constraints have been tried to employ on the attributes of a relation. Every attribute is bound
to have a specific range of values. For example, age cannot be less than zero and telephone numbers
cannot contain a digit outside 0-9.
Referential integrity Constraints
Referential integrity constraints work on the concept of Foreign Keys. A foreign key is a key attribute
of a relation that can be referred in other relation. Referential integrity constraint states that if a relation
refer to a key attribute of a different or same relation, then that key element must exist.
(or)
5.

Consider the following sample database :

Person(name, age, gender) Frequents(name, pizzeria) Eats(name, pizza)


Serves(pizzeria, pizza, price)
Write the Relational Algebraic Expression, TRC, DRC, SQL Expressions for the following
Queries.
1. Find all pizzas eaten by at least one female over the age of 20.
Relational Algebraic Expression :
Pizzeria(age<20 & gender=female(PERSON) FREQUENTS)
TRC :
{T | P PERSON, F FREQUENTS (P.NAME=F.NAME P.AGE >20 P.GENDER
=FEMALE T.PIZZERIA =F.PIZZERIA)

DRC
{P | N,A,G PERSON, NA,P FREQUENTS (N=NA A >20 G=FEMALE)
SQL
Select pizzeria from PERSON, FREQUENTS where
PERSON.NAME=FREQUENT.NAME AND age> 20 AND gender=FEMALE;
2. Find all pizzerias that serve at least one pizza for less than $10 that either Ramu
or Raju (or both) eat.
Relational Algebraic Expression :

Pizzeria(NAME=RAMU OR NAME=RAJU)(EATS) PRICE<10(SERVES))


TRC
{T | E EATS ,S SERVES (E.PIZZA=S.PIZZA E.NAME=RAMU E.NAME=RAJU
S.PRICE<10 T.PIZZERIA =F.PIZZERIA)

DRC
{PI | N,PE EATS, PI,PS,PR SERVES (PE=PS N=RAMU N=RAJU
PR<10)

SQL
Select pizzeria from EATS,SERVES where EATS.PIZZA=SERVES.PIZZA AND
EATS.NAME=RAMU OR EATS.NAME=RAJU AND SERVES.PRICE<10;
3. Find all pizzas that are eaten only by people younger than 24, or that cost less than
$10 everywhere they're served.
Relational Algebraic Expression :

Pizza(age<24 (PERSON) PRICE<10(SERVES) EATS)


TRC
{T | P PERSON ,S SERVES,E EATS (E.PIZZA=S.PIZZA P.NAME=E.NAME
S.PRICE<10 P.AGE<24 T.PIZZA=E.PIZZA)

DRC
{PE |PN,A,G PERSON, EN,PE EATS, PI,PS,PR SERVES (PE=PS
PN=EN A<24 PR<10)

SQL
Select eats. pizza from PERSON,EATS,SERVES where
EATS.PIZZA=SERVES.PIZZA AND EATS.NAME=SERVES.NAME AND
SERVES.PRICE<10 AND PERSON.AGE<24;
4. Find the age of the oldest person (or people) who eat mushroom pizza.
Relational Algebraic Expression :
AGE(MAX(Age)(PERSON) PIZZA=MUSHROOM)(EATS))
TRC
{T | P PERSON E EATS (P.NAME=E.NAME E.PIZZA=MUSHROOM
T.PIZZA=MAX(E.PIZZA))

DRC
{A |PN,A,G PERSON, EN,PE EATS ( PN=EN A=MAX(A)
PE=MUSHROOM)

SQL
Select max(age) from PERSON,EATS where EATS.NAME=SERVES.NAME AND
EATS.pizza=MUSHROOM;

5. Find all pizzerias that serve only pizzas eaten by people over 30.
Relational Algebraic Expression :
Pizzeria(age>30 (PERSON) FREQUENTS)
TRC :
{T | P PERSON(P.AGE>30) , F FREQUENTS (P.NAME=F.NAME T.PIZZERIA
=F.PIZZERIA)

DRC
{P | N,A,G PERSON(A>30), NA,P FREQUENTS (N=NA)
SQL
Select pizzeria from PERSON, FREQUENTS where
PERSON.NAME=FREQUENTS.NAME AND age> 30;

ADITYA COLLEGE OF ENGINEERING


PUNGANUR ROAD, MADANAPALLE-517325
II-B.Tech(R13) II-Sem I-Internal Examinations Sep-2016 (Objective)
13A05301 Database Management Systems ( CSE )
Time: 20 min
Name: _____________________
_________________

Answer all questions

Max Marks: 10
Roll NO:

3 1 =3 M

1. Describe Generalization and Aggregation.

Going up in this structure is called generalization, where entities are clubbed together to
represent a more generalized view. The reverse is called specialization where entities are split
for a specific view.
2. List any five Codds Rules.

Rule 1: Information Rule


The data stored in a database, may it be user data or metadata, must be a value of some table
cell. Everything in a database must be stored in a table format.
Rule 2: Guaranteed Access Rule
Every single data element (value) is guaranteed to be accessible logically with a combination
of table-name, primary-key (row value), and attribute-name (column value). No other means,
such as pointers, can be used to access data.
Rule 3: Systematic Treatment of NULL Values
The NULL values in a database must be given a systematic and uniform treatment. This is a
very important rule because a NULL can be interpreted as one the following data is missing,
data is not known, or data is not applicable.
Rule 4: Active Online Catalog
The structure description of the entire database must be stored in an online catalog, known as
data dictionary, which can be accessed by authorized users. Users can use the same query
language to access the catalog which they use to access the database itself.
Rule 5: Comprehensive Data Sub-Language Rule
A database can only be accessed using a language having linear syntax that supports data
definition, data manipulation, and transaction management operations. This language can be
used directly or by means of some application. If the database allows access to data without any
help of this language, then it is considered as a violation.
Rule 6: View Updating Rule
All the views of a database, which can theoretically be updated, must also be updatable by the
system.
Rule 7: High-Level Insert, Update, and Delete Rule
A database must support high-level insertion, updation, and deletion. This must not be limited
to a single row, that is, it must also support union, intersection and minus operations to yield
sets of data records.
Rule 8: Physical Data Independence
The data stored in a database must be independent of the applications that access the database.
Any change in the physical structure of a database must not have any impact on how the data
is being accessed by external applications.
Rule 9: Logical Data Independence
The logical data in a database must be independent of its users view (application). Any change
in logical data must not affect the applications using it. For example, if two tables are merged
or one is split into two different tables, there should be no impact or change on the user
application. This is one of the most difficult rule to apply.
Rule 10: Integrity Independence
A database must be independent of the application that uses it. All its integrity constraints can
be independently modified without the need of any change in the application. This rule makes
a database independent of the front-end application and its interface.
Rule 11: Distribution Independence

The end-user must not be able to see that the data is distributed over various locations. Users
should always get the impression that the data is located at one site only. This rule has been
regarded as the foundation of distributed database systems.
Rule 12: Non-Subversion Rule
If a system has an interface that provides access to low-level records, then the interface must
not be able to subvert the system and bypass security and integrity constraints.
Note : Any five can be answered in the above case.
3. Differentiate Weak Entity & Strong Entity.
An entity set that does not have a primary key is referred to as a weak entity set. The
existence of a weak entity set depends on the existence of a strong entity set; it must relate to
the strong set via a one-to-many relationship set. of attributes that distinguishes among all the
entities of a weak entity set.
4. Define View. Write the syntax for creating a view.
A view in SQL is a logical subset of data from one or more tables. View is used to restrict
data access.
The basic CREATE VIEW syntax is as follows:
CREATE VIEW view_name AS SELECT column1, column2..... FROM table_name
WHERE [condition];
5. List and explain the aggregate functions in SQL.
AVG() - Returns the average value.
COUNT() - Returns the number of rows.
FIRST() - Returns the first value.
LAST() - Returns the last value.
MAX() - Returns the largest value.
MIN() - Returns the smallest value.
SUM() - Returns the sum.

Choose the correct answer from the following

51 =5

1. In the relational modes, degree is termed as:


(A) Number of tuples. (B) Number of attributes.
(C) Number of tables. (D) Number of constraints.
[
B ]
2. Cartesian product in relational algebra is
(A) A Unary operator (B) A Binary operator (C) A Ternary operator (D) Not defined [
B ]
3. DML is provided for
(A) Description of logical structure of database. (B) Addition of new structures in the database
system.
(C) Manipulation & processing of database.
(D) Definition of physical structure of database
system. [ C
]
4. The database schema is written in
(A) HLL
(B) DML (C) DDL
(D) DCL
[ C
]
5. In an E-R diagram attributes are represented by
(A) Rectangle (B) Square (C) Ellipse.
(D) Triangle.
[ C
]
6. In case of entity integrity, the primary key may be
(A) not Null (B) Null (C) both Null & not Null. (D) any value.
[
A
]
7. The language which has recently become the defacto standard for interfacing Application
programs with relational database system is
(A) Oracle
(B) SQL
(C) Dbase
(D) 4GL
[
B ]
8. 'WHERE clause is used in SQL for
(A) Selection operation (B) Rename operation (C) Join operation. (D) Projection operation. [ A ]
9. A table with 4 attributes is joined with another table with 5 attributes. What are the resulting
number of attributes?
(A) 9 (B) 20 (C) Zero
(D) None
[
B
]
10. Relational Algebra is a _______________ query language.
(A) Procedural (B) Programming
(C) Declarative
(D) All the above
[ A
]

Das könnte Ihnen auch gefallen