Int I QB
Int I QB
PART A (2 Marks)
1. List any four differences between file processing system and DBMS
Logical data independence: The ability to change the Conceptual (Logical) schema without
changing the External schema (User View) is called logical data independence. For example, the
addition or removal of new entities, attributes, or relationships to the conceptual schema or
having to rewrite existing application programs.
Physical data independence: The ability to change the physical schema without changing
the logical schema is called physical data independence. For example, a change to the internal
schema, such as using different file organization or storage structures, storage devices, or
indexing strategy, should be possible without having to change the conceptual or external
schemas.
5. What is data model? What is the purpose of Data Model?
Data Model is a logical structure of Database.
Purpose of Data Model is the design of database to describe entities, attributes,
relationship among data, constrains etc.
1
6. What are the different types of data models?
2
11. State about the two levels of data independence
Logical data independence: The ability to change the Conceptual (Logical) schema without
changing the External schema (User View) is called logical data independence. For example,
the addition or removal of new entities, attributes, or relationships to the conceptual schema or
having to rewrite existing application programs.
Physical data independence: The ability to change the physical schema without changing
the logical schema is called physical data independence. For example, a change to the internal
schema, such as using different file organization or storage structures, storage devices, or
indexing strategy, should be possible without having to change the conceptual or external
schemas.
18. What is the difference between primary key & super key?
Primary key: The key that is selected to identify tuples uniquely within the relation
Example : ID
Super Key: An attribute or set of attributes that uniquely identifies a tuple within a relation
Example : ID, Address
19. What is candidate key?
The minimal set of attribute which can uniquely identify a tuple is known as candidate key.
For Example, STUD_NO in STUDENT relation.
20. What is E-R diagram? What are the elements of E-R diagram?
E-R diagram shows the complete logical structure of a database. An ER diagram shows the
relationship among entity sets.
E-R diagram has three main components:
1. Entity
2. Attribute
3. Relationship
21. Give example for one to one relationship and one to many relationship
4
One to One Relationship : For example, a person has only one passport and a passport is given to
one person.
One to Many Relationship : For example – a customer can place many orders but a order cannot be
placed by many customers.
5
Q1. With neat diagram, explain the structure/Component of a DBMS
6
2. Storage Manager Components :
They provide the interface between the low-level data stored in the database and
application programs and queries submitted to the system.
• Authorization and Integrity Manager : It tests for the satisfaction of integrity constraints
checks the authority of users to access data.
• Transaction Manager : It ensures that the database remains in a consistent state
despite the system failures and that concurrent transaction execution proceeds without
conflicting.
• File Manager : It manages the allocation of space on disk storage and the data
structures used to represent information stored on disk.
• Buffer Manager : It is responsible for fetching data from disk storage into main memory
and deciding what data to cache in memory.
3. Data Structures :
Following data structures are required as a part of the physical system implementation.
• Data Files : It stores the database.
• 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.
__________________________________________________________________
Q2. What is data model? Explain the different types of data models with
relevant examples.
Data Model is a logical structure of Database. It describes the design of database to
reflect entities, attributes, relationship among data, constrains etc.
Types os Data Models
E-R Model
Relational Model
Hierarchical Model
Network Model
Object oriented Model
7
Entity Relationship Diagram (ER Diagram)
An ER diagram shows the relationship among entity sets. An entity set is a group of similar
entities and these entities can have attributes. In terms of DBMS, an entity is a table or
attribute of a table in database, so by showing relationship among tables and their
attributes, ER diagram shows the complete logical structure of a database.
8
3. Relationship
A relationship is represented by diamond shape in ER diagram, it shows the relationship
among entities. There are four types of relationships:
1. One to One
2. One to Many
3.Many to One
4. Many to Many
RELATIONAL MODEL
In relational model, the data and relationships are represented by collection of inter-related
tables.
Each table is a group of column and rows, where column represents attribute of an entity and
rows represents records.
tables are also known as relations in relational model.
Rows are also known as tuples in relational model
7. Keys : To Identify Unique rows in a table Example Primary Key, candidate key, Super key,
foreign key and alternate key
9
Hierarchical model
In hierarchical model, data is organized into a tree like structure with each record
is having one parent record and many children.
The main drawback of this model is that, it can have only one to many relationships
between nodes.
Note: Hierarchical models are rarely used now.
Sample Hierarchical Model Diagram:
Lets say we have few students and few courses and a course can be assigned to a single
student only, however a student take any number of courses so this relationship becomes
one to many.
Network Model
This is an extension of the Hierarchical model. In this model data is organised more like a
graph, and are allowed to have more than one parent node.
10
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. This database model was used to map many-to-many data relationships.
This was the most widely used database model, before Relational Model was introduced.
It can represent redundancy in data more efficiently than that in the hierarchical model.
There can be more than one path from a previous node to successor node/s.
The operations of the network model are maintained by indexing structure of linked list
(circular) where a program maintains a current position and navigates from one record to
another by following the relationships in which the record participates.
Records can also be located by supplying key values.
11
Q3. Explain various operations of relation algebra with examples
Basic/Fundamental Operations:
1. Select (σ)
2. Project (∏)
3. Union (∪)
4. Set Difference (-)
5. Cartesian product (X)
6. Rename (ρ)
7. Intersection (∩)
Query:
∏Student_Name(COURSE)∩∏Student_Name(STUDENT)
Output:
Student_Name
------------
Aditya
13
Steve
Paul
Lucy
14
Rename (ρ) Example
Lets say we have a table customer, we are fetching customer names and we are renaming
the resulted relation to CUST_NAMES.
Query:
ρ(CUST_NAMES,∏(Customer_Name)(CUSTOMER))
Draw any E-R Diagram and Show the attributes and relationships .
RDBMS stands for Relational DataBase Management System. A relational model can be
represented as a table of rows and columns. A relational database has following major
components:
1. Table
2. Record or Tuple
3.Field or Column name or Attribute
4.Domain
5.Instance
6.Schema
7. Keys
1. Table
A table is a collection of data represented in rows and columns. Each table has a name in
database. For example, the following table “STUDENT” stores the information of students
in database.
Table: STUDENT
Student_Id Student_Name Student_Addr Student_Age
101 Chaitanya DayalBagh, Agra 27
102 Ajeet Delhi 26
103 Rahul Gurgaon 24
104 Shubham Chennai 25
2. Record or Tuple
Each row of a table is known as record. It is also known as tuple. For example, the
following row is a record that we have taken from the above table.
15
102 Ajeet Delhi 26
4. Domain
A domain is a set of permitted values for an attribute in table. For example, a domain of
month-of-year can accept January, February,…December as values, a domain of dates
can accept all possible valid dates etc. We specify domain of attribute while creating a
table.
An attribute cannot accept values that are outside of their domains. For example, In the
above table “STUDENT”, the Student_Id field has integer domain so that field cannot
accept values that are not integers for example, Student_Id cannot has values like, “First”,
10.11 etc.
6. Keys :
Key is used for identifying unique rows from table. It also establishes relationship
among tables.
Primary Key – A primary is a column or set of columns in a table that uniquely identifies
tuples (rows) in that table.
Super Key – A super key is a set of one of more columns (attributes) to uniquely identify rows
in a table.
16
Candidate Key – A super key with no redundant attribute is known as candidate key
Alternate Key – Out of all candidate keys, only one gets selected as primary key, remaining
keys are known as alternate or secondary keys.
Composite Key – A key that consists of more than one attribute to uniquely identify rows
(also known as records & tuples) in a table is called composite key.
Foreign Key – Foreign keys are the columns of a table that points to the primary key of
another table. They act as a cross-reference between tables.
Table: Employee
{Emp_SSN}
{Emp_Number}
{Emp_SSN, Emp_Number}
{Emp_SSN, Emp_Name}
{Emp_SSN, Emp_Number, Emp_Name}
{Emp_Number, Emp_Name}
Candidate Keys: As I mentioned in the beginning, a candidate key is a minimal super key
with no redundant attributes. The following two set of super keys are chosen from the
above sets as there are no redundant attributes in these sets.
{Emp_SSN}
{Emp_Number}
Only these two sets are candidate keys as all other sets are having redundant attributes
that are not necessary for unique identification.
17
Primary key: A Primary key is selected from a set of candidate keys. This is done by database
admin or database designer. We can say that either {Emp_SSN} or {Emp_Number} can be
chosen as a primary key for the table Employee.
Q6. Define a functional dependency. List and discuss the six inference rules for
functional dependencies. Give relevant examples.
A functional dependency (FD) is a relationship between two attributes, typically between the PK
and other non-key attributes within a table.
For any relation R, attribute Y is functionally dependent on attribute X (usually the PK), if for every
valid instance of X, that value of X uniquely determines the value of Y.
18
If X ⊇ Y then X → Y
Example:
If X → Y then XZ → YZ
Example:
If X → Y and Y → Z then X → Z
Example:
If X → Y and X → Z then X → YZ
Example:
If X → Y and YZ → W then XZ → W
Example:
_-----------------------------------------------------------------------------------------------------------------
PART C
20
1. External level
It is also called view level. The reason this level is called “view” is because several users can view
their desired data from this level which is internally fetched from database with the help of
conceptual and internal level mapping.
The user doesn’t need to know the database schema details such as data structure, table definition
etc. user is only concerned about data which is what returned back to the view level after it has been
fetched from database (present at the internal level).
External level is the “top level” of the Three Level DBMS Architecture.
2. Conceptual level
It is also called logical level. The whole design of the database such as relationship among data,
schema of data etc. are described in this level.
Database constraints and security are also implemented in this level of architecture. This level is
maintained by DBA (database administrator).
3. Internal level
This level is also known as physical level. This level describes how the data is actually
stored in the storage devices. This level is also responsible for allocating space to the
data. This is the lowest level of the architecture.
View of Data in DBMS
To fully understand the view of data, you must have a basic knowledge of data abstraction
and instance & schema. Refer these two tutorials to learn them in detail.
1. Data abstraction
2. Instance and schema
1. Data Abstraction in DBMS
Database systems are made-up of complex data structures. To ease the user interaction
with database, the developers hide internal irrelevant details from users. This process of
hiding irrelevant details from user is called data abstraction.
21
Three levels of abstraction:
Physical level abstraction: This is the lowest level of data abstraction. It describes
how data is actually stored in database. You can get the complex data structure
details at this level.
Logical level abstraction: This is the middle level of 3-level data abstraction
architecture. It describes what data is stored in database.
View level abstraction: Highest level of data abstraction. This level describes the
user interaction with database system.
2. Instance and schema in DBMS
In this guide, we will learn what is an instance and schema in DBMS.
DBMS Schema
Definition of schema: Design of a database is called the schema. Schema is of three
types: Physical schema, logical schema and view schema.
For example: In the following diagram, we have a schema that shows the relationship
between three tables: Course, Student and Section. The diagram only shows the design of
the database, it doesn’t show the data present in those tables. Schema is only a structural
view(design) of a database as shown in the diagram below.
physical schema : The design of a database at physical level is called physical schema,
how the data stored in blocks of storage is described at this level.
logical schema :Design of database at logical level is called logical schema,
programmers and database administrators work at this level, at this level data can be
described as certain types of data records gets stored in data structures, however the
internal details such as implementation of data structure is hidden at this level (available at
physical level).
22
view schema Design of database at view level is called view schema. This generally
describes end user interaction with database systems.
DBMS Instance
Definition of instance: The data stored in database at a particular moment of time is
called instance of database. Database schema defines the variable declarations in tables
that belong to a particular database; the value of these variables at a moment of time is
called the instance of that database.
For example, lets say we have a single table student in the database, today the table has
100 records, so today the instance of the database has 100 records. Lets say we are
going to add another 100 records in this table by tomorrow so the instance of database
tomorrow will have 200 records in table. In short, at a particular moment the data stored in
database is called the instance, that changes over time when we add or delete data from
the database.
Answer:
i)
ii)
iii)
23
Q3. Consider the Sailors-Boats-Reserves DataBase.
S (sid, sname, rating, age)
B (bid, bname, color)
R (sid, bid, date)
Answer:
24