Beruflich Dokumente
Kultur Dokumente
DBMS QUESTIONS
1.)
Define: Schema, Sub-schema, Instances, Entity, Attribute, and
Domain.
Schema: It is the set of formulas that specify integrity constraints imposed on
database.
Sub-schema: In database management, an individual user's partial view of the
database is called sub-schema.
Instances: The information stored in database at the particular movement is called
instance.
Entity: It represents the field of database.
Attribute: It is a column of table in database.
Domain: It is set of permissible value of an attributes.
2.)
Explain with examples different types of Attributes.
Simple Attributes: Attributes which cant be divided into subparts are called Simple
Attributes.
For example, Age of a person is simple attribute, Employee Number is simple
Attribute.
Composite Attributes: Attributes which can be divided into subparts. These
subparts are basic attributes with independent meanings of their own.
For example, Name of a person is composite attribute as it can be further divided
into First Name, Middle Name and Last Name.
Single Valued Attribute: A single valued attribute can have only a single value.
For example a person can have only one 'date of birth', 'age' etc. That is a single
valued attributes can have only single value. But it can be simple or composite
attribute. That is 'date of birth' is a composite attribute, 'age' is a simple attribute.
But both are single valued attributes.
Multi Valued Attribute: Multi valued attributes can have multiple values. For
instance a person may have multiple phone numbers, multiple degrees etc.
Derived Attribute: An attribute thats value is derived from a stored attribute.
For example, age and its value are derived from the stored attribute Date of Birth.
2|Page
3.)
One One
One Many
Many One
Many Many
One- One Relationship:
In this type of relationship, one attribute of a particular table is associated with
only one attribute of another table.
For example, An Instructor is associated with only one student via advisor.
A Student is associated with only one Instructor via advisor.
3|Page
4.)
Explain different types of keys with examples.
Super Key: Super key is a set of one or more attributes that are taken collectively
whose values or tuple is identified uniquely.
For example, Enrollment no., Email Id of Student table are super keys of that
particular table.
Candidate key: It is not proper subset of super key. The content of super key can be
a candidate key but not vice versa.
For example, Enrollment No. is a candidate key as it is a super key but no subsets
of it is super key.
Primary key: It is a candidate key which represents a particular attributes whose
values are unique and not NULL.
4|Page
5.)
Explain enhanced entity relationship models with following:
a.) Specialization
b.) Generalization
c.)Categorization.
d.) Aggregation
Specialization: It is a top down process that designates sub grouping entity set that
are distinct from other entities in the set. The attributes are inherited to lower level
entity set from higher level entity set.
person
ID
Name
address
student
tot_credits
employee
salary
instructor
rank
secretary
hours_perwe
ek
5|Page
6.)
Advantages and Disadvantages of DBMS.
Advantages:
i. Reduces data redundancy.
ii. Reduces errors and increase the level of consistency.
iii. Greater data integrity and independence from application programs.
iv. Improved Data security.
v. Improved data access to users through use of host and query languages.
vi. Many people can access same database at same time from anywhere.
Disadvantages
i.
Database systems are complex, difficult and time taking to design.
ii.
Substantial hardware and software start up costs.
iii.
Initial training is required for all programmers and users.
7.)
Advantages and Disadvantages of File system.
Advantages
i.
There is not much requirement when it comes to facility. Just some spaces are
required to continue.
ii.
It is user friendly in case of training as just a little training is required for it.
iii.
It is less expensive.
Disadvantages
i.
File description are stored with each application program that access a given
file.
ii.
There are chances of duplication of data in file system as it is manually done.
iii.
In case, if we want a particular data from all the stored data then its much
difficult to fetch out as the users have to sequentially go through each and
every data files.
iv.
There is no security or is less secured.
8.)
Explain levels of Abstraction of data in DBMS.
OR Explain the View of data in DBMS.
There are three levels of Data Abstraction in DBMS. They are:
i.
Internal Level/ Physical level Storage views.
ii.
Conceptual Level/Logical Level/Community users views.
iii.
External Level/Individual users views.
Internal Level:
- This level is the lowest level representation of the entire database. It is
described by means of internal schema.
- The internal level is all about how data are stored actually, what physical
sequence the stored records are in and so on. The internal schema is written
using data definition language (the internal DDL).
Conceptual Level:
6|Page
This level is the next higher level of abstraction which describes what data are
stored in the database and what relationships exist among those data. Thus, it
is the representation of the entire information content of the database in the
way; user wants to see rather than as users is forced to see by limitation.
The Logical level describes the entire database in terms of small number of
relatively simpler structures but implementation of simpler structures may
involve complex physical-level structures of which the user doesnt need to be
aware. This is referred to as physical data independence.
The conceptual view consists of many occurrences of many types of conceptual
records. For example, it might consist of a collection of department record
occurrences, plus a collection of employee record occurrences, plus a collection
of supplier record occurrences and so on.
The conceptual view is defined by means of conceptual schema, which includes
definitions of each of the various conceptual records types.
External Level:
- The highest level of abstraction describes only part of the entire database.
- Even though the Logical Level uses simpler structures, complexity remains
because of the variety of information stored in large database. Many users dont
need all this information; instead, they need to access only a part of database.
The External level of abstraction exists to simplify their interaction with the
system.
9.)
Explain the Database Languages.
There are four types of Database languages. They are:
i.
DML (Data Manipulation Language)
ii.
DDL (Data Definition Language)
iii.
DCL (Data Control Language)
iv.
TCL (Transaction Control Language)
7|Page
10.)
Explain different types of database users.
There are three types of database users. They are:
i.
Database Administrator (DBA)
ii.
Application developers
iii.
Applications end users
Database Administrator
- DBA are the one who design and build the DBMS product and the only ones who
can work on its code. No other than DBA can know about coding behind the
product.
- For example, ORACLE, My SQL, etc.
- A database administrators responsibilities can include the following:
i.
Installing and upgrading database server and application tools.
ii.
Allocating system storage and planning future storage requirements for
the database system.
iii.
Creating primary database storage structures after application developers
have designed the application.
iv.
Creating primary objects (tables, views, indexes) once application
developers have designed an application.
v.
Modifying database structures, as necessary, from information given by
application developers.
vi.
Enrolling users and maintaining system security.
vii.
Planning for backup and recovery of the database information.
Application developers
- They are the one to design and create application that uses DBMS and after that
design the needed database and maintain it. The responsibilities of Application
developers include the following tasks:
i.
Designing and developing the database application.
ii.
Designing the database structures for an application.
iii.
Estimating storage requirements for an application.
8|Page
iv.
v.
11.)
Define: Schema diagram, Relational data model, Relational query
language and Relational algebra.
Schema diagram: It is a pictorial depiction of the schema of a database that shows
the relations in the database, their attributes and primary keys and foreign keys.
Relational data model: It is based on a collection of tables. The user of a database
may query these tables, insert new tuples, delete tuples, and update (modify)
tuples.
Relational query language: It defines a set of operations that operate on tables,
and output tables as their results. These operations can be combined to get
expressions that express desired queries.
Relational Algebra: It provides a set of operations that take one or more relations
as input and return a relation as an output. Practical query languages such as SQL
are based on the relational algebra, but add a number of useful syntactic features.
12.)
Explain database system architecture with diagram in detail.
The Database systems can be centralized, or client-server, where one server
machine executes work on behalf of multiple client machines. Database systems
can also be designed to exploit parallel computer architectures.
Most users of the database system today are not present at the site of the
database system, but connect to it through a network. We can therefore
differentiate between client machines, on which remote database users work, and
server machines, on which the database system runs.
Nave users
(tellers, agents,
Application
programmers
web users)
use
Sophisticated
users
(analysis)
write
Application
interfaces
use
Query
tools
Application
programs
Compiler &
linker
Application
program
object code
DML queries
Buffer
dat
indice
use
Administration
tools
DDL
interpreter
DML
compiler &
organizer
Query
evaluation
engine
processor
Database
administrator
Data
File
manager
dictionary
Statistical
query
Authorization &
integrity
Transaction
storage
manager
9|Page
disk storage
System architecture
Database applications are usually partitioned into two or three parts. In a two-tier
architecture, the application resides at the client machine, where it invokes
database system functionally at the server machine through query language
statements.
In a three-tier architecture, the client machine acts as merely a front end and does
not contain any direct database calls. Instead, the client end communicates with
an application server, usually through a forms interface. The application server in
turn communicates with a database system to access data.
users
client
application
users
application
network
database system
network
Application
server
Database system
10 | P a g e
server
(a)
architecture
architecture
Two-tier
(b) Three-tier
13.)
Explain Relational Query Languages.
A query language is a language in which user requests information from the
database. These languages are usually on a level higher than that of a standard
programming language. Query languages can be categorized as either procedural
or nonprocedural.
In procedural language, the user instructs the system to perform a sequence of
operations on the database to get the desired result.
In nonprocedural language, the user describes the desired information without
giving a specific procedure for obtaining that information.
Schema of the University database is as follow:
classroom(building, room_number, capacity)
department(dept_name, building, budget)
course(course_id, title, dept_name, credits)
instructor(ID, name, dept_name, salary)
student(stu_ID, name, dept_name, tot_cred)
Query languages are used in both ways i.e. procedural and nonprocedural. There
are number of pure query languages: The relational algebra is procedural,
whereas the tuple relational calculus and domain relational calculus are
nonprocedural.
The relational algebra is a set of operations that take one or two relations as input
and procedure a new relation as their result. The relational calculus uses predicate
logic to define the result as desired without giving any specific algebraic
procedure.
14.)
Explain Relational Operations with example.
There are six basic operators/ operations which all procedural relational query
languages have. They are:
i.
Select :
ii.
Project :
iii.
Rename :
iv.
Union :
v.
Set difference :
vi.
Cartesian Product : x
Select Operation:
- The Select operations select the tuples satisfying given condition.
(branch_name) = Anand (Bank)
11 | P a g e
In the above example, is the select operator after that is the condition in
which except the operators, others are in subscript and in the end is the table
name in parenthesis.
The comparisons can be done using =, , , <, >.
(amount) > 10000 (Bank)
Several conditions can be combined by using (AND), (OR) and (NOT).
(branch_name) = Anand amount = 10000 (Bank)
Relation : r
A
A
B
B
1
2
3
4
1
1
1
2
= (r)
In the above example, the select operation show us the relation as per the
condition given and the one which dont follow the condition are hidden/ left
out.
Project Operation:
- The Project operation is a unary operation (operate on one relation) that returns
its argument relations, with certain attributes left out.
-
The attributes which we want is to be listed with and the table name in the
parenthesis. It can be shown as below:
branch_name,amount(Bank)
Relation: r
,(r)
A
A
B
B
1
2
3
4
1
1
4
5
A
B
B
1
4
5
A
B
B
1
4
5
12 | P a g e
In the above example, the project operation shows us the attributes which are
in the condition and rest are left out. In this example, the repeated relations are
shown just once.
Composition of relational operators can be shown as below:
branch_name,amount(loan_no=2948755428(Bank))
Rename:
- The Rename operation is an unary operator used to rename the attributes of
relation. It can be shown as:
a/b(r)
- Here, b attribute of the relation r is renamed to a attribute.
- For example, to rename branch_name attribute to cust_city of the relation
Bank, we can do as follow:
cust_city/branch_name(Bank)
Union:
- The union operation is binary operator (operate on pairs of relation). For union
operator, the relations to which we are using Union operator should have same
attributes and also the domains of all the attributes of those relations must be
same. It can be shown as below:
cust_name(Borrower) cust_name(Depositer)
-
Relation: r,s
A
A
B
1
2
1
A
B
2
3
r
-
r s:
A
A
B
B
1
2
1
3
13 | P a g e
In the above example, the union operation shows us all the set of attributes of
both the relations and the repeated ones are just shown once.
Set difference:
- The Set difference operation is a binary operator which works as set
intersection. The two relations involved in set interactions must also be unioncompatible. It can be shown as below:
cust_name(Borrower)
cust_name(Depositer)
-
Relation: r,s
A
A
B
1
2
1
A
B
2
3
r
-
s:
A
B
B
1
1
3
In the above example, the set operation shows us the tuples other than those
which are in both the relations.
Cartesian product: x
- The Cartesian product operation is a binary operator used to combine each
tuple of one relation to each tuple of another relation. It can be shown as R x S.
- Relation: r,s
r x s:
A
1
A
2
B
3
B
4
A
1
A
1
A
2
A r2
B
3
B
3
B
4
B
4
E
F
E
F
E
F
E
F
E
F
14 | P a g e
15.)
Explain Entity Relationship Model
The entity-relational (E-R) data model was developed to facilitate database design
by allowing specification of an enterprise schema that represents the overall
logical structure of a database.
The E-R model is very useful in mapping the meaning and interactions of real-world
problem into a conceptual schema. The E-R model employs three basic concepts:
entity sets relationship sets, and the attributes.
Entity Sets: An entity is a thing or object that is present in the real word which is
distinguishable from all other objects. For example, each person in the university is
an entity. An entity has a set of properties and the values for some set of
properties may uniquely identify an entity.
An entity set is a set of entities of the same type that share the same properties, or
attributes. For example, a group of people who are instructor in the University can
be defined as the entity set instructor. An entity is represented by a set of
attributes. Attributes are the detailed information possessed by each member in an
entity set. For example, Instructor entity may have attributes ID, Name,
dept_name and salary.
Each entity has a value for its attributes. For example, a particular instructor entity
may have the value GT31001 for ID, the value Karan for Name, the value CSE for
dept_name and the value 50000 for salary.
Instructor
15 | P a g e
Rectangle shape divided into two parts indicates an Entity Set. The first part
represents an Entity set and the second part represents the attributes of that
particular entity.
Relationship Sets: A relationship is an association among several entities. For,
example, we can define a relationship advisor that associates instructor Karan with
the student Ranvijay. This means relationship specifies that Karan is an advisor of
student Ranvijay.
A Relationship set is a set of relationships of the same type. Formally, it is a
mathematical relation on n 2 (possibly non distinct) entity sets. If E1, E2, , En
are entity sets, then a relationship set R is a subset of
{(e , e , .., e ) |e E , e E , , e E }
1
The number of entity sets that participate in a relationship set is the degree of the
relationship set. A binary relationship set is of degree 2; a ternary relationship set
is of degree 3.
advisor
16 | P a g e
described by a set of (attribute, data value) pairs, one pair for each attribute of the
entity set. For example, a particular instructor may be described by the set
{(ID,GT31001),(Name, Karan),(dept_name, CSE),(salary,50000)}, meaning that the
entity describes a person named Karan whose instructor ID is GT31001, who is a
member of CSE department with the salary of 50000. The attribute values
describing an entity constitute a significant portion of the data stored in the
database.
An attribute, as used in the E-R model, can be characterized by the following
attribute types.
Simple Attributes: Attributes which cant be divided into subparts are called Simple
Attributes.
For example, Age of a person is simple attribute, Employee Number is simple
Attribute.
Composite Attributes: Attributes which can be divided into subparts. These
subparts are basic attributes with independent meanings of their own.
For example, Name of a person is composite attribute as it can be further divided
into First Name, Middle Name and Last Name.
Single Valued Attribute: A single valued attribute can have only a single value.
For example a person can have only one 'date of birth', 'age' etc. That is a single
valued attributes can have only single value. But it can be simple or composite
attribute. That is 'date of birth' is a composite attribute, 'age' is a simple attribute.
But both are single valued attributes.
Multi Valued Attribute: Multi valued attributes can have multiple values. For
instance a person may have multiple phone numbers, multiple degrees etc.
Derived Attribute: An attribute thats value is derived from a stored attribute.
For example, age and its value are derived from the stored attribute Date of Birth.
16.)
Explain Weak Entity Set.
An entity set that does not have sufficient attributes to from a primary key is
termed as weak entity set. An entity set that has a primary key is termed as solid
entity set.
For a weak entity set to be meaningful, it must be associated with another entity
set, called indentifying or owned entity set. Every weak entity must be associated
with an identifying entity; that is, the weak entity set is to be existence dependent
on the identifying entity set. The relationship associating the weak entity set with
the identifying entity set is called identifying relationship.
The discriminator of a weak entity set is a set of attributes that allows the
distinction to be made among the entities in the weak entity set that depends on
one particular strong entity. For example, the discriminator of the weak entity set
section consists of attributes sec_id, year and semester, since, for each course, this
set of attributes uniquely identifies one single section for that course. The
discriminator of weak entity set is also called partial key of the set.
The primary key of the weak entity set is formed by the primary of the identifying
entity set, plus the weak entity sets discriminator. In case of the entity set section,
its primary key is {course_id, sec_id, yaer, semester}, where course_id is the
primary key of the identifying entity set, namely course, and {sec_id, year,
semester) distinguishes section entities for the same course.
17 | P a g e
In E-R diagrams, a weak entity set is depicted via rectangle, like a strong entity set,
but there are two main differences:
- The discriminator of a weak entity in underlined with a dashed, rather than a
solid line.
- The relationship set connecting the weak entity set to the identifying strong set
is depicted by a double diamond.