Beruflich Dokumente
Kultur Dokumente
Max Marks: 30
3 10 =30 M
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.
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.
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.
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.
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.
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.
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.
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.
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 :
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 :
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;
Max Marks: 10
Roll NO:
3 1 =3 M
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.
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.
51 =5