DBMS QB Ans
DBMS QB Ans
A database is a collection of data, typically describing the activities of one or more related
organizations.
A database management system, or DBMS, is software designed to assist in maintaining and utilizing
large collections of data.
Data Independence: In a database system, the database management system provides the interface
between the application programs and the data.
Improved Data Sharing: DBMS allows a user to share the data in any number of application
programs.
Security: Having complete authority over the operational data, enables the DBA in ensuring that the
only mean of access to the database is through proper channels.
Efficient Data Access: In a database system, the data is managed by the DBMS and all access to the
data is through the DBMS providing a key to effective data processing.
Databases change over time as information is inserted and deleted. The collection of information
stored in the database at a particular moment is called an instance of the database.
Double line between entity set “Student” and relationship set “Enrolled In” signifies total
participation. It specifies that each student must be enrolled in at least one course. Single line
between the entity set “course” and relationship set “enrolled In” signifies partial participation. It
specifies that there might exists some courses for which no enrolments have been made.
5 How to represent the strong Entity set and Weak entity set in ER-Model?
• Physical level (or Internal View / Schema): The lowest level of abstraction describes how the data
are actually stored. The physical level describes complex low-level data structures. It explains various
types of stored records, what indexes exist, and so on.
• Logical level (or Conceptual View / Schema): The next-higher level of abstraction describes what
data are stored in the database, and what relationships exist among those data. This level of
abstraction is used by Database Administrator (DBA).
• View level (or External View / Schema): The highest level of abstraction describes only part of the
database which are requested by the user, but not the entire database. The view level of abstraction
exists to simplify their interaction with the system
4. General constraints
Selection (σ): Selection operator is used to select tuples from a relation based on some condition. A
new relation is created by selecting only those rows requested by the user satisfying a specified
condition.
E.g: σ (AGE>18)(STUDENT)
Projection (π): The projection eliminates all attributes of the input relation but those mentioned in
the projection list. That means all other unnecessary fields are projected out.
A relational database query as a question about the and the answer consisting of a new relation
containing the result.
Division is typically required when you want to find out entities that are interacting with all entities of
a set of different type entities. The division operator is used when we have to evaluate queries which
contain the keyword ‘all’.
y : column of S R(x,y) div S(y) means gives all distinct values of x from R that are associated
with all values of y in S.
ALTER TABLE : ALTER TABLE modifies the structure of an existing table. To add a column called
maiden-name to Students, for example, we would use the following command:
{< a1, a2, a3, … an > | P(a1, a2, a3, … an)} Where a1, a2, a3, … an are attributes of the relation and P
is the condition. Here each attribute is given a variable name
LONG ANSWERS
1 Compare and Contrast File Systems with Database Systems.
2 Discuss about different types of Data Models.
DATA MODELS: A Database model defines the logical design and structure of a database and defines
how data will be stored, accessed and updated in a database management system.
Relational model: The most common model, the relational model sorts data into tables, also known
as relations, each of which consists of columns and rows. Each column lists an attribute of the entity.
Hierarchical Model: This model organizes data into a tree-like-structure, with a single root, to which
all the other data is linked. The hierarchy starts from the Root data, and expands like a tree, adding
child nodes to the parent nodes.
Network Model: This is an extension of the Hierarchical model. In this model data is organized in
the form of graph, and are allowed to have more than one parent node. In this database model data
is more related as more relationships are established in this database model. Also, as the data is
more related, hence accessing the data is also easier and fast.
APPLICATIONS:
◦ Accounting: For payments, receipts, account balances, assets and other accounting information.
◦ Human resources: For information about employees, salaries, payroll taxes, and benefits, and for
generation of pay checks.
◦ Manufacturing: For management of the supply chain and for tracking production of items in
factories, inventories of items in ware houses and stores, and orders for items. Online retailers: For
sales data noted above plus online order tracking, generation of recommendation lists, and
maintenance of online product evaluations.
◦ Credit card transactions: For purchases on credit cards and generation of monthly statements.
◦ Finance: For storing information about holdings, sales, and purchases of financial instruments such
as stocks and bonds; also, for storing real-time market data to enable online trading by customers
and automated trading by the firm.
• Universities: For student information, course registrations, and grades (in addition to standard
enterprise information such as human resources and accounting).
• Airlines: For reservations and schedule information. Airlines were among the first to use databases
in a geographically distributed manner.
• Telecommunication: For keeping records of calls made, generating monthly bills, maintaining
balances on prepaid calling cards, and storing information about the communication networks.
DATA ABSTRACTION:
Data abstraction is the process of hiding unwanted and irrelevant details from the end
user.
It helps to store information in such a way that the end user can access data which is
necessary, the user will not be able to see what data is stored or how it is stored in a
database.
Data abstraction helps to keep data secure from unauthorized access and it hides all the
implementation details.
Levels of Abstraction:
There are three levels of data abstraction in DBMS that are mentioned below:
It is the lowest level of data abstraction which defines how data is stored in database.
It defines data structures used to store data and methods to access data in database.
It defines what data is present in database and their relationships between them .
There are different levels of views and each view defines only a part of whole data
required to user.
This level defines many views of same database for simplification of view to user.
DATA INDEPENDENCE:
Data Independence is the ability to change the schema at one level of a database system
without affecting the schema at the next higher level.
It is important because it allows changes in the data structure without disrupting application
programs or the way users interact with the data.
The ability to change the physical storage of data (how data is stored) without affecting the
logical schema (what data is stored and its relationships).
It allows changes in the hardware or file organization without impacting application
programs or user views.
The ability to change the logical schema (the structure of data and relationships) without
affecting the external schema or application programs.
It provides flexibility in modifying the database structure, such as adding new fields or
changing relationships, without disturbing the user interface or applications.
DML Pre-compiler: It translates DML statements in a query language into low level instructions that
query evaluation engine understands. It also attempts to transform user's request into an equivalent
but more efficient form.
DDL Interpreter: It interprets the DDL statements and records them in a set of tables containing
meta data or data dictionary.
Query Evaluation Engine: It executes low-level instructions generated by the DML compiler.
Application program object code: These are the low-level instructions of the programs written by
the users, which query evaluation engine understands and execute them.
Storage Manager:
A storage manager is a program module that provides the interface between the low-level data
stored in the database and the application programs and queries submitted to the system. The
storage manager is responsible for the interaction with the file manager. The storage manager
components include:
Authorization and integrity manager, which tests for the satisfaction of integrity constraints and
checks the authority of users to access data.
Transaction manager, which ensures that the database remains in a consistent (correct) state
despite system failures, and that concurrent transaction executions proceed without conflicting.
File manager, which manages the allocation of space on disk storage and the data structures used
to represent information stored on disk.
Buffer manager, which is responsible for fetching data from disk storage into main memory, and
deciding what data to cache in main memory. The buffer manager is a critical part of the database
system, since it enables the database to handle data sizes that are much larger than the size of main
memory.
Lock Manager: Keep tracks of request for locks and grant locks on data.
Recovery manager: Responsible for maintaining a log and restoring system to consistent state after
a crash.
Following data structures are required as a part of the physical system implementation.
• Data Dictionary: It stores meta data (data about data) about the structure of the database.
• Indices: Provide fast access to data items that hold particular values.
• Statistical Data: It stores statistical information about the data in the database. This information is
used by query processor to select efficient ways to execute query.
6 What is ER model? Explain the basic symbols used for entities, attributes and relationships.
ER Diagram
The ER or (Entity Relational Model) is a high-level conceptual data model diagram. Entity- Relation
model is based on the notion of real-world entities and the relationship between them. ER modeling
helps you to analyze data requirements systematically to produce a well-designed database.
ER- Diagram is a visual representation of data that describe how data is related to each other.
Lines: It links attributes to entity types and entity types with other relationship types
Attribute(s)
Entities are represented by means of their properties, called attributes. For example, Roll_No, Name,
DOB, Age, Address, Mobile No are the attributes of Student. In ER diagram, attribute is represented
by an oval.
1. Key Attribute: The attribute which uniquely identifies each entity in the entity set is called key
attribute. For example, Roll No will be unique for each student. In ER diagram, key attribute is
represented by an oval with underlying lines.
2. Composite Attribute: An attribute that can be divided into smaller independent attribute is known
as composite attribute. For example, Address attribute of student Entity type consists of Street, City,
State, and Country. In ER diagram, composite attribute is represented by an oval comprising of ovals.
3. Single Valued Attribute: An attribute that has only single value for an entity is known as single
valued attribute.
4. Multivalued Attribute: An attribute that can have multiple values for an entity is known as multi
valued attribute. For example, Phone_No (can be more than one for a given student). In ER diagram,
multivalued attribute is represented by double oval.
5. Derived Attribute An attribute which can be derived from other attributes is known as derived
attribute. e.g.; Age (can be derived from DOB). In ER diagram, derived attribute is represented by
dashed oval.
6. Null-Valued-Attribute An attribute, which has not any value for an entity is known as null valued
attribute. For example, assume Student is an entity and its attributes are Name, Age, Address and
Phone no. There may be chance when a student has no phone no. In that case, phone no is called
null valued attributes.
8 What is Key? Distinguish between Super key, Candidate key, Primary Key, Foreign Key for a relation
with examples.
Keys in a Database
In a relational database, a key is an attribute or a set of attributes that uniquely identifies a tuple
(row) in a relation (table). Keys are crucial in ensuring data integrity and avoiding duplication.
Types of Keys
1. Super Key
o A super key is a set of one or more attributes that can uniquely identify a tuple in a
relation.
{Student_ID}
{Student_ID, Email}
{Student_ID, Phone}
2. Candidate Key
{Student_ID}
{Email}
3. Primary Key
o Example: In the Student table, we can choose Student_ID as the primary key.
4. Foreign Key
o A foreign key is an attribute (or a set of attributes) in one table that references the
primary key of another table.
19 Let R =(ABC) and S=(DEF) let r(R) and s(S) be relations on schema R and S. Give an expression in
the Domain relational calculus that is equivalent to each of the following. i) σB=25(r) ii) ∏A,F,
( σC=D(rXs))
20 Consider the following relations Sailors (sid, sname, rating, age) Boats (bid, bname, color)
Reserves (sid, bid, day) Write the statements in Relational Algebra, Relational Calculus, Domain
Relational Calculus and SQL for the following questions. a) Find the names of sailors who have
reserved a Red boat. b) Find the names of sailors who have reserved at least one boat. c) Find the
names of sailors who have reserved a Red and a Green boat. d) Find the names of sailors who have
reserved a Red or a White boat. e) Find the names of sailors who have reserved all boats
21 Consider the following relational schema. Student (id, name, age, city) Retrieve the names of all
students. Display the id’s of all students who are having age above 20. Display the names and id’s of
all students who are having age between 20 and 25 and lives in Hyderabad city.
23 Define trigger and explain its three parts? Differentiate row level and statement level triggers