WordPress Websites for Engineers: Elevate Your Brand
Dbms question (3)
1. 1|P a g e
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 can’t 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 that’s value is derived from a stored attribute.
For example, age and its value are derived from the stored attribute Date of Birth.
3.) Explain mapping constraints.
One – One One – Many
2. 2|P a g e
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.
Many – One Relationship:
In this type of relationship, many attributes of a particular table is associated with only one attribute of
another table.
For example, Many Instructors are advising only one student.
One - Many Relationship:
In this type of relationship, only one attribute of particular table is associated with many attributes of
another table.
For example, An instructor is advising many students.
3. 3|P a g e
Many – Many Relationship:
In this type of relationship, many attributes of particular table is associated with many attributes of
another table.
For example, Many instructors are advising many students.
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.
For example, Enrollment No. is a primary key of student table as it is unique of particular student. It is
not possible that students have same Enrollment No and also that a student is without Enrollment No.
Foreign key: Foreign key is a primary key of another table. Any attribute of a particular table is a
foreign key if that attribute is derived from another table and is also a primary key of that table.
For example, If student ID is a primary key of student table then it can be used as a foreign key in Exam
table where the name can be known of student with the help of student ID.
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.
4. 4|P a g e
person
ID
Name
address
employee student
salary tot_credits
instructor secretary
rank hours_perweek
Specialization & Generalization
Generalization: It is a bottom up process. It combines the entities having same features into a higher
level entity set.
Aggregation: Aggregation is an abstraction in which relationship sets are treated as higher level entity
sets. Here a relationship set is embedded inside an entity set, and these entity sets can participate in
relationships.
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.
5. 5|P a g e
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 it’s 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:
- 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 doesn’t 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 don’t need all this information; instead, they
6. 6|P a g e
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)
DML (Data Manipulation Language)
- It is used/ function is to manipulate data.
- It consist Commands like INSERT, DELETE, MERGE, UPADTE.
- INSERT command add tuples/ attributes to an existing table.
- DELETE command removes existing tuples / attributes from a table.
- UPDATE command modifies a set of existing table tuples/attributes.
- MERGE command is used to combine the data of multiple tables.
DDL (Data Definition Language)
- DDL manages the table and index structure.
- It consist Commands like CREATE, ALTER, DROP, TRUNCATE and REPLACE.
- CREATE Command creates an object(table) in the database.
- ALTER Command modifies the structure of an existing object in various ways.
- TRUNCATE Command deletes all data from a table in a very fast way, deleting the data inside table
and not the table itself.
- DROP Command deleted an object in database usually that cannot be ‘ROLL BACK’.
- REPLACE Command is used to rename the table.
DCL (Data Control Language)
- DCL authorizes users or a group of users to access and manipulate data.
- It consist Commands like GRANT and REVOKE.
- GRANT Command authorizes one or more users to perform an operation or a set of operations on
an object.
- REVOKE Command eliminates a grant which were given to users.
TCL (Transaction Control Language)
- TCL deals with transaction of data i.e. to completely remove or save the data as per requirements.
- It consist Commands like COMMIT and ROLLBACK.
- COMMIT Command causes all data changes in a transaction to be made permanent.
- ROLLBACK Command causes all data changes since the last COMMIT or ROLLBACK to be discarded,
leaving the state of data as it was prior to those changes.
10.) Explain different types of database users.
There are three types of database users. They are:
i. Database Administrator (DBA)
ii. Application developers
7. 7|P a g e
iii. Application’s 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 administrator’s 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.
iv. Specifying modifications of database structure for an application.
v. Establishing security measures for an application during development.
Application end users
- They are the one that interact with application or utilities. A typical end user’s responsibilities
includes following tasks:
i. Entering, modifying or deleting the data, where permitted.
ii. Generating reports from the data.
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.
8. 8|P a g e
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 user’s work, and server machines, on which the database system runs.
Naïve users Application Sophisticated Database
(tellers, agents, web programmers users administrator
users) (analysis)
use write use use
Application Application Query Administration
interfaces programs tools tools
Compiler & DML queries DDL interpreter
linker
Application DML compiler
program object & organizer
code
Query evaluation
engine
query processor
Buffer manager File manager Authorization & Transaction
integrity manager manager
storage manager
disk storage
indices Data
dictionary
data Statistical data
System architecture
9. 9|P a g e
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 users
client
application application
network network
database system Application server
server
Database system
(a) Two-tier architecture (b) Three-tier architecture
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)
10. 10 | P a g e
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)
- 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 1 1
A 2 1
B 3 1
B 4 2
- σβ = γ (r)
α β γ
A 1 1
- In the above example, the select operation show us the relation as per the condition given and the
one which don’t follow the condition are hidden/ left out.
11. 11 | P a g e
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 α β γ
A 1 1
A 2 1
B 3 4
B 4 5
- ∏σ,γ(r)
α γ α γ
A 1 A 1
=
A 1 B 4
B 4 B 5
B 5
- 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)
12. 12 | P a g e
- Relation: r,s α β α β
A 1 A 2
A 2 B 3
B 1
r s
- r ∪ s:
α β
A 1
A 2
B 1
B 3
- 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 union-compatible. It can be shown as below:
∏cust_name(Borrower) ∏cust_name(Depositer)
- Relation: r,s α β α β
A 1 A 2
A 2 B 3
B 1
r s
- r s: α β
A 1
B 1
B 3
- In the above example, the set operation shows us the tuples other than those which are in both the
relations.
13. 13 | P a g e
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
α β γ
A 1 E
A 2 F
B 3
B 4
r s
- r x s:
α β γ
A 1 E
A 1 F
A 2 E
A 2 F
B 3 E
B 3 F
B 4 E
B 4 F
- In the above example Cartesian product operation shows us the combination of each tuple of
relation r to each tuple of relation s.
14. 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 E-R Symbol for Entity set
ID
name
salary
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
{(e1, e2, .., en) |e1 E1, e2 E2, … , en En}
Where (e1, e2, .., en) is a relationship.
A relationship can always be not possible with a single valued attributes i.e. it may sometime require
more values to represent. For such case, we should create a multi-valued attribute.
It is not necessary that there is only one relation between the several entities. There may be chances
for two relations between the entities or three relation or many more. For example, a student and
instructor are associated with proj_guide but there may be chances that those two entity sets are also
associated with eval_for. This is shown in below figure.
15. 15 | P a g e
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 E-R symbol relationship sets
Diamond shape represents relationship sets.
Attributes: For each attribute, there is a set of permitted values, called the domain, or value set of that
attribute.
Formally, an attribute of an entity set is a function that maps from the entity set into domain. Since, an
entity set may have several attributes; each entity can be 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 can’t 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 that’s 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.
16. 16 | P a g e
The primary key of the weak entity set is formed by the primary of the identifying entity set, plus the
weak entity set’s 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.
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.
Double lines indicate total participation of an entity in a relationship set.
Double diamonds represent identifying relationship sets link to weak entity set.