0% found this document useful (0 votes)
4 views

UNIT-1 DBMS (1)

This document provides an introduction to Database Management Systems (DBMS), defining key terms such as data, information, databases, and metadata. It discusses the disadvantages of traditional file systems compared to DBMS, highlighting issues like data redundancy, inconsistency, and security problems, while also outlining the advantages of DBMS including minimal data redundancy, improved data access, and security. Additionally, it covers the roles of a Database Administrator (DBA), the ANSI SPARC architecture, mapping, data independence, and different types of database users.

Uploaded by

shrutikakumari76
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

UNIT-1 DBMS (1)

This document provides an introduction to Database Management Systems (DBMS), defining key terms such as data, information, databases, and metadata. It discusses the disadvantages of traditional file systems compared to DBMS, highlighting issues like data redundancy, inconsistency, and security problems, while also outlining the advantages of DBMS including minimal data redundancy, improved data access, and security. Additionally, it covers the roles of a Database Administrator (DBA), the ANSI SPARC architecture, mapping, data independence, and different types of database users.

Uploaded by

shrutikakumari76
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

UNIT-1 Introduction of DBMS

Define the following terms.


Data
Fact that can be recorded or stored.
E.g. Person Name, Age, Gender and Weight etc.
Information
When data is processed, organized, structured or presented in a given context so as to
make it useful, it is called information.
Database
A Database is a collection of inter-related (logically-related) data.
E.g. Books Database in Library, Student Database in University etc.
DBMS (Database Management System)
A database management system is a collection of inter-related data and set of programs to
manipulate those data.
DBMS = Database + Set of programs
E.g. MS SQL Server, Oracle, My SQL, SQLite, MongoDB etc.
Metadata
Metadata is data about data.
Data such as table name, column name, data type, authorized user and user access privileges
for any table is called metadata for that table.
Data dictionary
Data dictionary is an information repository which contains metadata. It
is usually a part of the system catalog.
Data warehouse
Data warehouse is an information repository which stored data. It is
design to facilitate reporting and analysis.
Field
A field is a character or group of characters that have a specific meaning.
It is also called a data item. It is represented in the database by a value.
For Example customer id, name, society and city are all fields for customer Data.
Record
A record is a collection of logically related fields.
For examples, collection of fields (id, name, address & city) forms a record for customer.
Explain disadvantages of file system (file processing systems) compare to Database
management system. OR Explain
disadvantages of conventional file-based system
compared to Database management system.
Data Redundancy
It is possible that the same information may be duplicated in different files. This leads to
data redundancy.
Data redundancy results in memory wastage.
For example, consider that some customers have both kinds of accounts - saving and
current. In this case, data about customers such as name, address, e-mail and contact
number will be duplicated in both files, saving accounts file and current account file.
In other words, same information will be stored in two different locations (files). And, it
wastes memory.
Data Inconsistency
Due to data redundancy, it is possible that data may not be in consistent state.
For example, consider that an address of some customer changes. And, that customer has
both kinds of accounts. Now, it is possible that this changed address is updated in only
one file, leaving address in other file as it is. As a result of this, same customer will have
two different addresses in two different files, making data inconsistent.
Difficulty in Accessing Data
Accessing data is not convenient and efficient in file processing system.
For example, suppose, there is a program to find information about all customers. But,
what if there is a need to find out all customers from some particular city. In this case,
there are two choices here: One, find out all customers using available program, and then
extract the needed customers manually. Second, develop new program to get required
information. Both options are not satisfactory.
For each and every different kind of data access, separate programs are required. This is
neither convenient nor efficient.
Limited Data Sharing
Data are scattered in various files.
Different files may have different formats. And these files may be stored in different
folders (directories) may be of different computers of different departments.
So, due to this data isolation, it is difficult to share data among different applications.
Integrity Problems
Data integrity means that the data contained in the database is both correct and consistent.
For this purpose, the data stored in database must satisfy certain types of constraints
(rules).
For example, a balance for any account must not be less than zero. Such constraints are
enforced in the system by adding appropriate code in application programs. But, when
new constraints are added, such as balance should not be less than Rs. 5000, application
programs need to be changed. But, it is not an easy task to change programs whenever
required.
Atomicity Problems
Any operation on database must be atomic. This means, operation completes either 100%
or 0%.
For example, a fund transfer from one account to another must happen in its entirely. But,
computer systems are vulnerable to failure, such as system crash, virus attack. If a system
failure occurs during the execution of fund transfer operation, it may possible that
amount to be transferred, say, Rs. 500, is debited from one account, but is not credited to
another account.
This leaves database in consistent state. But, it is difficult to ensure atomicity in a file
processing system.
Concurrent Access Anomalies
Multiple users are allowed to access data simultaneously (concurrently). This is for the
sake of better performance and faster response.
Consider an operation to debit (withdrawal) an account. The program reads the old
balance, calculates the new balance, and writes new balance back to database. Suppose an
account has a balance of Rs. 5000. Now, a concurrent withdrawal of Rs. 1000 and Rs.
2000 may leave the balance Rs. 4000 or Rs. 3000 depending upon their completion time
rather than the correct value of Rs. 2000.
Here, concurrent data access should be allowed under some supervision.
But, due to lack of co-ordination among different application programs, this is not
possible in file processing systems.
Security Problems
Database should be accessible to users in a limited way.
Each user should be allowed to access data concerning his application only.
For example, a customer can check balance only for his/her own account. He/She should
not have access for information about other accounts.
But, in file processing system, application programs are added in an ad hoc manner by
different programmers. So, it is difficult to enforce such kind of securityconstraints.
Explain advantages (benefits) of DBMS over file management system. OR
Explain purpose of database system.
Minimal Data Redundancy (Duplication)
Due to centralized database, it is possible to avoid unnecessary duplication of
information.
This leads to reduce data redundancy.
It prevents memory wastage and reduces extra processing time to get required data.
Shared Data
All authorized user and application program can share database easily.
Data Consistency
Data inconsistency occurs due to data redundancy.
With reduced data redundancy such type of data inconsistency can be eliminated.
This results in improved data consistency.
Data Access
DBMS utilizes a variety of techniques to retrieve data.
Required data can be retrieved by providing appropriate query to the DBMS.
Thus, data can be accessed in convenient and efficient manner.
Data Integrity
Data in database must be correct and consistent.
So, data stored in database must satisfy certain types of constraints (rules).
DBMS provides different ways to implement such type of constraints (rules).
This improves data integrity in a database.
Data Security
Database should be accessible to user in a limited way.
DBMS provides way to control the access to data for different user according to their
requirement.
It prevents unauthorized access to data.
Thus, security can be improved.
Concurrent Access
Multiple users are allowed to access data simultaneously.
Concurrent access to centralized data can be allowed under some supervision.
This results in better performance of system and faster response.
Guaranteed Atomicity
Any operation on database must be atomic. This means, operation must be executed
either 100% or 0%.
This type of atomicity is guaranteed in DBMS.
List and explain the applications of DBMS.
Airlines and railways
Airlines and railways use online databases for reservation, and for displaying the schedule
information.
Banking
Banks use databases for customer inquiry, accounts, loans, and other transactions.
Education
Schools and colleges use databases for course registration, result, and other information.
Telecommunications
Telecommunication departments use databases to store information about the
communication network, telephone numbers, record of calls, for generating monthly bills,
etc.
Credit card transactions
Databases are used for keeping track of purchases on credit cards in order to generate
monthly statements.
E-commerce
Integration of heterogeneous information sources (for example, catalogs) for business
activity such as online shopping, booking of holiday package, consulting a doctor, etc.
Health care information systems and electronic patient record
Databases are used for maintaining the patient health care details in hospitals.
Digital libraries and digital publishing
Databases are used for management and delivery of large bodies of textual and
multimedia data.
Finance
Databases are used for storing information such as sales, purchases of stocks and bonds
or data useful for online trading.
Sales
Databases are used to store product, customer and transaction details.
Human resources
Organizations use databases for storing information about their employees, salaries,
benefits, taxes, and for generating salary checks.
Describe functions (responsibility, roles, and duties) of DBA to handle DBMS.
DBA
The full name of DBA is Database Administrator.
Database Administrator is a person in the organization who controls the design and the
use of database.
Functions or Responsibilities of DBA are as under:
Schema Definition
DBA defines the logical schema of the database.
A schema refers to the overall logical structure of the database.
According to this schema, database will be designed to store required data for an
organization.
Storage Structure and Access Method Definition
DBA decides how the data is to be represented in the database.
Based on this, storage structure of the database and access methods of data is defined.
Defining Security and Integrity Constraints
DBA decides various security and integrity constraints.
DDL (Data Definition Language) provides facilities to specifying such constraints.
Granting of Authorization for Data Access
The DBA determines which user needs access to which part of the database.
According to this, various types of authorizations (permissions) are granted to different
users.
This is required to prevent unauthorized access of a database.
Liaison with Users
DBA is responsible to provide necessary data to user.
User should be able to write the external schema, using DDL (Data Definition Language).
Assisting Application Programmers
DBA provides assistance to application programmers to develop application programs.
Monitoring Performance
The DBA monitors performance of the system.
The DBA ensures that better performance is maintained by making change in physical or
logical schema if required.
Backup and Recovery
Database should not be lost or damaged.
The task of DBA is to backing up the database on some storage devices such as DVD,
CD or Magnetic Tape or remote servers.
In case of failures, such as flood or virus attack, Database is recovered from this backup.
Explain three levels ANSI SPARC Database System. OR
Explain three level Data abstraction.
The ANSI SPARC architecture divided into three levels:
1) External level
2) Conceptual level
3) Internal level
Externa View A View B View C
l
Level

Conceptual View
Conceptua
l Level

Interna
l Internal View
Level

Three levels ANSI SPARC Database System


Internal Level
This is the lowest level of the data abstraction.
It describes how the data are actually stored on storage devices.
It is also known as a physical level.
The internal view is described by internal schema.
Internal schema consists of definition of stored record, method of representing the data
field and access method used.
Conceptual Level
This is the next higher level of the data abstraction.
It describes what data are stored in the database and what relationships exist among those
data.
It is also known as a logical level.
Conceptual view is defined by conceptual schema. It describes all records and
relationship.
External Level
This is the highest level of data abstraction.
It is also known as view level.
It describes only part of the entire database that a particular end user requires.
External view is describes by external schema.
External schema consists of definition of logical records, relationship in the external view
and method of deriving the objects from the conceptual view.
This object includes entities, attributes and relationship.
Explain Mapping. OR
Explain external and internal mapping. OR
What is mapping? Describe type of mapping.
Mapping
The process of transforming requests and results between the three levels is called
mapping.
Types of Mapping
Conceptual/Internal Mapping
External/Conceptual Mapping
Conceptual/Internal Mapping
It relates conceptual schema with internal schema.
It defines correspondence between the conceptual schema and the database stored in
physical devices.
It specifies how conceptual records and fields are presented at the internal level.
If the structure of stored database is changed, then conceptual/internal mapping must be
changed accordingly and conceptual schema can remain invariant.
There could be one mapping between conceptual and internal levels.
External/Conceptual Mapping
It relates each external schema with conceptual schema.
It defines correspondence between a particular external view and conceptual schema.
If the structure of conceptual schema is changed, then external/conceptual mapping must be
changed accordingly and external schema can remain invariant.
There could be several mappings between external and conceptual levels.
Explain Data Independence.
Data Independence
Data independency is the ability to modify a schema definition in one level without
affecting a schema definition in the next higher level.
Types of data independence
Physical data independence
Logical data independence
Physical data independence
Physical data independence allows changing in physical storage devices or organization
of file without change in the conceptual view or external view.
Modifications at the internal level are occasionally necessary to improve performance.
Physical data independence separates conceptual level from the internal level.
It is easy to achieve physical data independence.
Logical data independence
Logical data independence is the ability to modify the conceptual schema without
requiring any change in application programs.
Conceptual schema can be changed without affecting the existing external schema.
Modifications at the logical level are necessary whenever the logical structure of the
database is altered.
Logical data independence separates external level from the conceptual view.
It is difficult to achieve logical data independence.
Explain 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.
Explain different database users.
There are four different database users.
Application programmers
These users are computer professionals who write application programs using some tools.
E.g. Software developers
Sophisticated users
These users interact with system without writing program. They form their request in a
database query language. E.g. Analyst.
Specialized users
These users write specialized database applications that do not fit into the traditional data
processing framework. E.g. Database Administrator.
Naive users
These users are unsophisticated users who have very less knowledge of database system.
These users interact with the system by using one of the application programs that have
been written previously.
Examples, e.g. Clerk in bank
Differentiate the DA and DBA.
DA (Data Administrator) DBA (Database Administrator)
The data administrator is a person in the The database administrator is a person in the
organization who controls the data of the organization who controls the design and the
database. use of the database.
DA determines what data to be stored in DBA provides necessary technical support for
database based on requirements of the implementing a database.
organization.
DA is involved more in the requirements DBA is involved more in the design,
gathering, analysis, and design phases. development, testing and operationalphases.
DA is a manager or some senior level person DBA is a technical person having knowledge
in an organization who understands of database technology.
organizational requirements with respect to
data.
DA does not need to be a technical person, but DBA does not need to be a business person,
any kind of knowledge about database but any kind of knowledge about a
technology can be more beneficiary. functionality of an organization can be more
beneficiary.
DA is a business focused person, but, he/she DBA is a technically focused person, but,
should understand more about the database he/she should understand more about the
technology. business to administer the databases
effectively.
Explain Database System Architecture.
Components of a DBMS
These functional units of a database system can be divided into two parts:
1. Query Processor Units (Components)
2. Storage Manager Units
Query Processor Units:
Query processor unit deal with execution of DDL (Data Definition Language) and DML (Data
Manipulation Language) statements.
 DDL Interpreter — Interprets DDL statements into a set of tables containing metadata.
 DML Compiler — Translates DML statements into low level instructions that the
query evaluation engine understands.
 Embedded DML Pre-compiler — Converts DML statements embedded in an
application program into normal procedure caIls in the host language.
 Query Evaluation Engine — Executes low level instructions generated by DML
compiler.
Storage Manager Units:
Storage manager units provide interface between the low level data stored in database and
the application programs & queries submitted to the system.
 Authorization Manager — Checks the authority of users to access data.
 Integrity Manager — Checks for the satisfaction of the integrity constraints.
 Transaction Manager — Preserves atomicity and controls concurrency.
 File Manager — Manages allocation of space on disk storage.
 Buffer Manager — Fetches data from disk storage to memory for being used.
In addition to these functional units, several data structures are required to implement physical
storage system. These are described below:
Data Files — To store user data.
Data Dictionary and System Catalog — To store metadata. It is used heavily, almost
for each and every data manipulation operation. So, it should be accessed efficiently.
Indices — To provide faster access to data items.
Statistical Data — To store statistical information about the data in the database. This
information is used by the query processor to select efficient ways to execute a query.
Explain database system 3 tier architecture with clear diagram in detail.
Most widely used architecture is 3-tier architecture.
3-tier architecture separates it tier from each other on basis of users.

Presentation Tier
user client

application client
Application Tier
network

application server
Database Tier
server
database system

2 tier v/s 3 tier architecture


Database (Data) Tier
At this tier, only database resides.
Database along with its query processing languages sits in layer-3 of 3-tier architecture.
It also contains all relations and their constraints.
Application (Middle) Tier
At this tier, the application server and program, which access database, resides.
For a user this application tier works as abstracted view ofdatabase.
Users are unaware of any existence of database beyond application.
For database-tier, application tier is the user of it.
Database tier is not aware of any other user beyond application tier.
This tier works as mediator between the two.
User (Presentation) Tier
An end user sits on this tier.
From a user’s aspect, this tier is everything.
He/she doesn't know about any existence or form of database beyond this layer.
At this layer multiple views of database can be provided by the application.
All views which are generated by an application, resides in application tier.
2 – Data Models

Define the following terms.


Entity
An entity is a thing or object or person in the real world that is distinguishable from all
other object.
E.g. book, student, employee, collegeetc…
Entity sets
An entity set is a set of entities of same type that share the same properties or attributes.
E.g. the set of all students in a college can be defined as entity set student.
Relationship
Relationship is an association (connection) between several entities.
Relationship between 2 entities is called binary relationship.
E.g. book is issued by student where book and student are entities and issue is relation.
Relationship set
Relationship set is a set of relationships of the same type.
Attributes
Attributes are properties hold by each member of an entity set.
E.g. entity is student and attributes of student are enrollmentno, name, address, cpi etc
Types of attributes
Simple attribute: It cannot be divided into subparts. E.g. cpi, rollno
Composite attribute: It can be divided into subparts. E.g. name (first-name, middle-
name, last-name), address.
Single valued attribute: It has single data value. E.g. enrollmentno, birthdate
Multi valued attribute: It has multiple data value. E.g. phoneno (may have multiple
phones).
Stored attribute: It’s value is stored manually in database. E.g. birthdate
Derived attribute: It’s value is derived or calculated from other attributes. E.g. age (can
be calculated using current date and birthdate).
Descriptive attributes
A relationship may also have attributes like an entity. These attributes are called
descriptive attributes.
E.g. Student gets degree certificate on 14th March 2011. Student and Degree are entities,
gets certificate is relation and certificate date is an attribute of relationship.
2 – Data Models

student-name
Issue date

student-id Branch certi-no name

student issue degree certificate

Recursive relationship set


The same entity set participates in a relationship set more than once then it is called
recursive relationship set.
E.g. an employee entity participated in relationship under with department entity as an
employee as well manager also.

Degree of relationship
The degree of a relationship is the number of entity types that participate in the
relationship.
The three most common relationships in ER models are Unary, Binary and Ternary.
A unary relationship is when both participant entities in the relationship are the same
entity.
Example: Subjects may be prerequisites for othersubjects.

subject

is prerequisite for

A binary relationship is the relationship between two different entities.


The University might need to record which teachers taught which subjects.

teacher teaches subject

A ternary relationship is the relationship between three different entities.


The University might need to record which teachers taught which subjects in which
courses.

J
2 – Data Models

teacher teaches
subject

course

Explain various mapping cardinality (cardinality constraint).


Mapping cardinality (cardinality constraints)
It represents the number of entities of another entity set which are connected to an entity
using a relationship set.
It is most useful in describing binary relationship sets.
For a binary relationship set the mapping cardinality must be one of the following types:
One to one
One to many
Many toone
Many tomany
One-to-one relationship
A B

A1 ___________ B1

A2 ___________ B2

A3 B3

A4 ___________ B4

s
An entity in A is associated with at most (only) one entity in B and an entity in B is
associated with at most (only) one entity in A.

customer-name customer-address

customer-city loan-no amount


customer-id

customer borrower loan


J
A customer is connected with only one loan using the relationship borrower and a loan is
connected with only one customer using borrower.
One-to-many relationship
A B

A1 __________________________________ B1

A2 B2

A3 __________________________________ B3

A4 B4

An entity in A is associated with any number (zero or more) of entities in B and an entity
in B is associated with at most (only) one entity in A.

customer-name customer-address

loan-no amount
customer-id customer-city

customer borrower loan

In the one-to-many relationship a loan is connected with only one customer using borrower
and a customer is connected with more than one loans using borrower.
2 – Data Models

Many-to-one relationship
A B

A1 __________________________________ B1

A2 B2

A3 __________________________________ B3

A4 B4

An entity in A is associated with at most (only) one entity in B and an entity in B is


associated with any number (zero or more) of entities in A.

customer-name customer-address

loan-no amount
customer-id customer-city

customer borrower loan

In a many-to-one relationship a loan is connected with more than one customer using
borrower and a customer is connected with only one loan using borrower.
Many-to-many relationship
A B

A1 __________________________________ B1

A2 B2

A3 __________________________________ B3

A4 B4

J
2 – Data Models

An entity in A is associated with any number (zero or more) of entities in B and an entity
in B is associated with any number (zero or more) of entities in A.

customer-name customer-address

customer-id customer-city loan-no amount

customer borrower loan

A customer is connected with more than one loan using borrower and a loan is connected
with more than one customer using borrower.

Explain various participation constraints.


Participation constraints
It specifies the participation of an entity set in a relationship set.
There are two types participationconstraints
Total participation
Partial participation
Total participation
In total participation, every entity in the entity set participates in at least one relationship
in the relationship set.
It specifies that every entity in super class must be member of some of its sub class.
E.g. participation of loan in borrower is total because every loan must be connected to a
customer using borrower.
It is indicated by double line.
Partial participation
In partial participation, some entities may not participate in any relationship in the
relationship set.
It specifies that an entity may not belong to any sub class.
E.g. participation of customer in borrower is partial because every customer is not
connected to loan using borrower.
It is indicated by single line.

J
2 – Data Models

customer-name customer-address

customer-city loan-no amount


customer-id

customer borrower loan

Partial Participation Total Participation

Explain weak entity set with the help of example.


Weak entity set
An entity set that does not have a primary key is called weak entityset.
The existence of a weak entity set depends on the existence of a strong entity set.
Weak entity set is indicated by double rectangle.
Weak entity relationship set is indicated by double diamond.
The discriminator (partial key) of a weak entity set is the set of attributes that distinguishes
between all the entities of a weak entity set.
The primary key of a weak entity set is created by combining the primary key of the strong
entity set on which the weak entity set is existence dependent and the weak entity set’s
discriminator.
We underline the discriminator attribute of a weak entity set with a dashed line.
E.g. in below fig. there are two entities loan and payment in which loan is strong entity set
and payment is weak entity set.
Payment entity has payment-no which is discriminator.
Loan entity has loan-no as primary key.
So primary key for payment is (loan-no, payment-no).

payment-date

amount payment-no loan-amount


loan-no

loan loan-payment payment

Strong Entity
Weak Entity Relationship Weak Entity

J
2 – Data Models

Explain the Superclass and Subclass in E-R diagram with the help of example.
Superclass
A superclass is an entity from which another entity can be derived.
A superclass is a generic entity set which has a relationship with one or more subclasses.
For example, an entity set account has two subsets saving_account and
current_account. So an account is superclass.
Each member of subclass is also a member of superclass. So any saving account or a
current account is a member of entity set account.
Subclass
A subclass is an entity that is derived from another entity.
A class is a subset of entities in an entity set which has attributes distinct from those in
other subset.
For example, entities of the entity set account are grouped in to two classes
saving_account and current_account. So saving_account and current_account are
subclasses.
superclass
account

sublass saving account current account

Explain the difference between Specialization and


Generalization in E-R diagram.
Specialization Generalization
It will work in Top-down approach. It will work in Bottom-up approach
The process of creating sub-groupings within an The process of creating groupings from
entity set is called specialization. various entity sets is called generalization.
Specialization is a process of taking a sub set of Generalization is a process of taking the
higher level entity set to form a lower-level union of two or more lower-level entity sets
entity set. to produce a higher-level entity set.
Specialization starts from a single entity set; it Generalization starts from the number of
creates different low-level entity set using some entity sets and creates high-level entity set
different features. using some common features.
2 – Data Models

Explain Specialization and Generalization in E-R diagram with example.


For all practical purposes, generalization and specialization is inversion of each other.
Specialization
A top-down design process that creates subclasses based on some different characteristics
of the entities in the superclass.
An entity set may include sub groupings of entities that are distinct in some way from
other entities in the set.
For example, a subset of entities within an entity set may have attributes that are not shared
by all the entities in the entity set.
Consider an entity set person, with attributes name, street and city.
A person may be further classified as one of the following:
customer
Employee
For example, customer entities may be described further by the attribute customer-id,
credit-rating and employee entities may be described further by the attributes employee-id
and salary.
The process of designating sub groupings within an entity set is called specialization. The
specialization of person allows us to distinguish among persons according to whether they
are employees or customers.
Now again, employees may be further classified as one of the following:
officer
teller
secretary
Each of these employee types is described by a set of attributes that includes all the
attributes of entity set employee plus additional attributes.
For example, officer entities may be described further by the attribute office-number, teller
entities by the attributes station-number and hours-per-week, and secretary entities by the
attribute hours-per-week.
In terms of an E-R diagram, specialization is depicted by a triangle component labeled
ISA.
The label ISA stands for “is a” and represents, for example, that a customer “is a”
person.
The ISA relationship may also be referred to as a superclass subclass relationship.
Generalization
A bottom-up design process that combines number of entity sets that have same features
into a higher-level entity set.
The design process proceed in a bottom-up manner, in which multiple entity sets are
synthesized into a higher level entity set on the basis of common features.
2 – Data Models
The database designer may have to first identify a customer entity set with the attributes
name, street, city, and customer-id, and an employee entity set with the attributes name,
street, city, employee-id, and salary.
But customer entity set and the employee entity set have some attributes common. This
commonality can be expressed by generalization, which is a containment relationship that
exists between a higher level entity set and one or more lower level entity sets.
In our example, person is the higher level entity set and customer and employee are lower
level entity sets.
Higher level entity set is called superclass and lower level entity set is called subclass. So
the person entity set is the superclass of two subclasses customer and employee.
Differences in the two approaches may be characterized by their starting point and overall
goal.

name street city

person

salary ISA credit-rating

employee
customer

ISA

officer teller secretary

officer-number hours-worked

station-number hours-worked

Explain types of constraints on specialization and


Generalization.
There are mainly two types of constraints apply to a specialization/generalization:
Disjoint Constraint
Describes relationship between members of the superclass and subclass and indicates
whether member of a superclass can be a member of one, or more than one subclass.
2 – Data Models

It may be disjoint or non-disjoint (overlapping).


1. Disjoint Constraint
 It specifies that the subclasses of the specialization must be disjointed (an entity can be a
member of only one of the subclasses of the specialization).
 Specified by ‘d’ in EER diagram or by writing disjoint.
2. Non-disjoint (Overlapping)
 It specifies that is the same entity may be a member of more than one subclass of the
specialization.
 Specified by ‘o’ in EER diagram or by writing overlapping.

Participation Constraint
 Determines whether every member in super class must participate as a member of a
subclass or not.
 It may be total (mandatory) or partial (optional).
1. Total (Mandatory)
Total specifies that every entity in the superclass must be a member of some subclass in the
specialization.
Specified by a double line in EER diagram.
2. Partial (Optional)
Partial specifies that every entity in the super class not belong to any of the subclass of
specialization.
Specified by a single line in EER diagram.
Based on these two different kinds of constraints, a specialization or generalization can be
one of four types
 Total, Disjoint
 Total, Overlapping
 Partial, Disjoint
 Partial, Overlapping.

Explain aggregation in E-R diagram.


The E-R model cannot express relationships among relationships.
When would we need such a thing at that time aggregation is used.
Consider a database with information about employees who work on a particular project
and use a number of machines doing that work.
2 – Data Models

work

hours hours
name id number name id number

emp work project emp work project

uses work uses

machinery machinery
uses

id id
machinery

Fig. A Fig. B

Relationship sets work and uses could be combined into a single set. We can combine
them by using aggregation.
Aggregation is an abstraction through which relationships are treated as higher-level
entities.
For our example, we treat the relationship set work and the entity sets employee and
project as a higher-level entity set called work.
Transforming an E-R diagram with aggregation into tabular form is easy. We create a
table for each entity and relationship set as before.
The table for relationship set uses contains a column for each attribute in the primary
key of machinery and work.

Explain the steps to reduce the ER diagram to ER database schema.

Step 1: Entities and Simple Attributes:


An entity type within ER diagram is turned into a table. You may preferably keep the
same name for the entity or give it a sensible name but avoid DBMS reserved words as
well as avoid the use of special characters.
Each attribute turns into a column (attribute) in the table. The key attribute of the entity is
the primary key of the table which is usually underlined. It can be composite if required
but can never be null.
2 – Data Models

It is highly recommended that every table should start with its primary key attribute
conventionally named as TablenameID.
Consider the following simple ER diagram:

PersonID Person
Phone

Name
Address Email

The initial relational schema is expressed in the following format writing the table names
with the attributes list inside a parentheses as shown below
 Persons( personid, name, address, email )
Person
personid name address Email

Persons and Phones are Tables and personid, name, address and email are Columns
(Attributes).
personid is the primary key for the table : Person

Step 2: Multi-Valued Attributes


A multi-valued attribute is usually represented with a double-line oval.

PersonID Person
Phone

If you have a multi-valued attribute, take that multi-valued attribute and turn it into a new
entity or table of its own.
Then make a 1:N relationship between the new entity and the existing one.
In simple words.
 1. Create a table for that multi-valued attribute.
 2. Add the primary (id) column of the parent entity as a foreign key within the
new table as shown below:
 First table is Persons ( personid, name, address, email )
 Second table is Phones ( phoneid , personid, phone )
personid within the table Phones is a foreign key referring to the personid of Persons
Phone
phoneid personid phone
2 – Data Models
Step 3: 1:1 Relationship

WifeID Name
Wife

Have

PersonID Person
Phone

Name
Address Email

Let us consider the case where the Person has one wife. You can place the primary key of
the wife table wifeid in the table Persons which we call in this case Foreign key as shown
below.
 Persons( personid, name, address, email , wifeid )
 Wife ( wifeid , name )
Or vice versa to put the personid as a foreign key within the wife table as shown below:
 Persons( personid, name, address, email )
 Wife ( wifeid , name , personid)
For cases when the Person is not married i.e. has no wifeID, the attribute can set to
NULL
Persons Wife
personid name address email wifeid wifeid name

OR

Persons Wife
personid name address email wifeid name personid
2 – Data Models

Step 4: 1:N Relationships

HouseID House Name

Address
Has

PersonID Person
Phone

Name
Address Email

For instance, the Person can have a House from zero to many, but a House can have only
one Person.
In such relationship place the primary key attribute of table having 1 mapping in to the
table having many cardinality as a foreign key.
To represent such relationship the personid as the Parent table must be placed within the
Child table as a foreign key.
It should convert to :
 Persons( personid, name, address, email )
 House ( houseid, name , address, personid)
Persons House
personid name address email houseid name address personid

Step 5: N:N Relationships

CountryID Country Name

Has

PersonID Person
Phone

Name
Address Email
2 – Data Models

For instance, The Person can live or work in many countries. Also, a country can have
many people. To express this relationship within a relational schema we use a separate
table as shown below:
It should convert into :
 Persons( personid, name, address, email )
 Countries ( countryid, name)
 HasRelat ( hasrelatid, personid , countryid)
Persons Countries
personid name address email countryid name

HasRelat
hasrelatid personid Countryid

What is E-R model (Entity-Relationship) model (diagram) also draw various symbols using
in E-R diagram.
E-R model
Entity-relationship (ER) model/diagram is a graphical representation of entities and their
relationships to each other with their attributes.
2 – Data Models

What is a Database Models?


A database model is a type of data model that defines the logical structure of a database.
It determine how data can be stored, accessed and updated in a database management
system
The most popular example of a database model is the relational model, which uses a table-
based format.
Type of Database Models are:
1. Hierarchical Model
2. Network Model
3. Entity-relationship Model
4. Relational Model
5. Object-oriented database model

1. Hierarchical Model
The hierarchical model organizes data into a tree-like structure, where each record has a
single parent or root.

department

student professor
2 – Data Models

The hierarchy starts from the Root data, and expands like a tree, adding child nodes to the
parent nodes.
In hierarchical model, data is organized into tree-like structure with one-to-many
relationship between two different types of data, for example, one department can have
many professors and many students.

2. Network Model
This is an extension of the hierarchical model, allowing many-to-many relationships in a
tree-like structure that allows multipleparents.

B C

D E F

3. Entity-relationship Model
In this database model, relationships are created by dividing object of interest into entity
and its characteristics into attributes.

customer-name customer-address

customer-city loan-no amount


customer-id

customer borrower loan

4. Relational Model
In this model, data is organized in two-dimensional tables and the relationship is
maintained by storing a common attribute.
2 – Data Models
Rno StudentName Age SubjectID SubjectName Teacher
1 Raj 21 1 DBMS Patel
2 Meet 22 2 DS Shah

Rno SubjectID Marks


1 1 98
1 2 95
2 1 95
2 2 90
5. Object-oriented database model
This data model is another method of representing real world objects.
It considers each object in the world as objects and isolates it from each other.
It groups its related functionalities together and allows inheriting its functionality to other
related sub-groups.

What is Integrity Constraints?

Integrity constraints are a set of rules. It is used to maintain the quality of information.
Integrity constraints ensure that the data insertion, updating, and other processes have to be
performed in such a way that data integrity is not affected.
Thus, integrity constraint is used to guard against accidental damage to the database.
Various Integrity Constraints are:
1. Check
 This constraint defines a business rule on a column. All the rows in that
column must satisfy this rule.
 Limits the data values of variables to a specific set, range, or list of values.
 The constraint can be applied for a single column or a group of columns.
 E.g. value of SPI should be between 0 to 10.
2. Not null
 This constraint ensures all rows in the table contain a definite value for the
column which is specified as not null. Which means a null value is not
allowed.
 E.g. name column should have some value.
2 – Data Models
3. Unique
 This constraint ensures that a column or a group of columns in
each row have a distinct (unique) value.
 A column(s) can have a null value but the values cannot be duplicated.
 E.g enrollmentno column should have unique value.
4. Primary key
 This constraint defines a column or combination of columns
which uniquely identifies each row in the table.
 Primary key = Unique key + Not null
 E.g enrollmentno column should have unique value as well as can’t be
null.
5. Foreign key
 A referential integrity constraint (foreign key) is specified between two
tables.
 In the referential integrity constraints, if a foreign key column in
table 1 refers to the primary key column of table 2, then every
value of the foreign key column in table 1 must be null or be
available in primary key column of table 2.

You might also like