0% found this document useful (0 votes)
3 views24 pages

Dbms Lecture Notes Unit 1

The document contains lecture notes for the Database Management Systems course for B.Tech II Year students at GNITC for the academic year 2023-2024. It covers various topics including database applications, historical perspectives, data models, and comparisons between file systems and DBMS. Key concepts such as data independence, data integrity, and different database models like hierarchical, network, relational, and object-oriented are discussed in detail.

Uploaded by

nanisai3108
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views24 pages

Dbms Lecture Notes Unit 1

The document contains lecture notes for the Database Management Systems course for B.Tech II Year students at GNITC for the academic year 2023-2024. It covers various topics including database applications, historical perspectives, data models, and comparisons between file systems and DBMS. Key concepts such as data independence, data integrity, and different database models like hierarchical, network, relational, and object-oriented are discussed in detail.

Uploaded by

nanisai3108
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 24

LECTURE NOTES

DATABASE MANAGEMENT SYSTEMS


SUBJECT CODE: 22PC0CS09
B.TECH II Year-II Semester

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

AY: 2023-2024

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

LECTURE NOTES FOR THE ACADEMIC YEAR 2023-24

FACULTY NAME : M.Pradeep

SUBJECT : Database Management Systems

SUBJECT CODE : 22PC0CS09

YEAR : II

SEMESTER : II

STREAM : CSE

VERIFIED BY
HOD – SPECIAL BATCH

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


UNIT 1 – DATA BASE SYSTEM APPLICATIONS
CONTENTS:
1. Database System Applications:
i. A Historical Perspective
ii. File Systems versus a DBMS
iii. The Data Model
iv. Levels of Abstraction in a DBMS
v. Data Independence
vi. Structure of a DBMS

2. Introduction to Database Design :


i. Database Design and ER Diagrams
ii. Entities, Attributes, and Entity Sets,
iii. Relationships and Relationship Sets,
iv. Additional Features of the ER Model,
v. Conceptual Design With the ER Model

DATA BASE SYSTEM APPLICATIONS


DATA

 Data is a fact or figures or entity.


 When activities in the organization takes place, the effect of these activities need to be
recorded which is known as Data.

INFORMATION

 Processed data to carrying out useful the business activities is called information

DATABASE
A database is a collection of data, typically describing the activities of one or more related
organizations.
For example, a university database might contain information about the following:
 Entities such as students, faculty, courses, and classrooms.
 Relationships between entities, such as students' enrollment in courses, faculty
teaching courses, and the use of rooms for courses.

DATABASE MANAGEMENT SYSTEM


A database management system, or DBMS, is software designed to assist in maintaining
and utilizing large collections of data.

1.1 A HISTORICAL PERSPECTIVE


• From the earliest days of computers, storing and manipulating data have been a major
application focus. The first general-purpose DBMS, called the Integrated Data Store,
was designed by Charles Bachman in the early 1960s. It formed the basis for the
network data model.

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


• In the late 1960s, IBM developed the Information Management System (IMS)
DBMS which formed the basis for the hierarchical data model. The SABRE system
for making airline reservations was jointly developed by American Airlines and IBM
around the same time, and it allowed several people to access the same data through a
computer network.
• In 1070, Edgar Codd, at IBM's San Jose Research Laboratory, proposed the
relational data model. This sparked rapid development of several DBMSs based on
the relational model. The benefits of DBMS were widely recognized, and the use of
DBMSs for managing corporate data became standard practice.
 As the popularity of relational DBMS started increasing, soon, IBM, in early 1980s,
has developed a SQL (Structured Query Language) for relational databases through
their SYSTEM/R project.
• Later in late 1980s, SQL was standardized and the version SQL-1999 was adopted
by ANSI (American National Standard Institute and ISO (International Standards
Organization).
• During this period, the concept of concurrent execution of database programs,
called transactions, was introduced in DBMS system which allowed the user to run
their programs concurrently. Later in 1999, James Gray won Turing award for his
contributions to the field of database transaction management.
• In the late 1980s and the 1990s, advances have been made in many areas of database
systems. More emphasis is given on new data types such as images and text, and the
ability to support complex analysis of data within of an enterprise.
• Over a period of time, a new database system was created, data warehouses,
consolidating data from several databases, and for carrying out specialized analysis.
• By introduction of enterprise resource planning (ERP) and management resource
planning (MRP) packages exciting new features were added to existing database
system.
• Many other packages like Baan, Oracle, PeopleSoft, SAP, and Siebel which were user
friendly and allowed the user to carry out the task easily.
• Most significant change in DBMS is through integration of DBMS with internet
which allowed DBMS to store data accessed through web browser. It allowed the
users to write their queries through web forms, and the formatted output are
generated using a markup language such as HTML.
• Today the field is being driven by exciting visions such as multimedia databases,
interactive video, digital libraries and so on.
FILE SYSTEM vs DBMS
A File System is a collection of raw data files stored in the hard-drive. Files are created and
manipulated by writing programs so the permanent records are stored in various files.

The problems in file processing system are

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


 Data redundancy and inconsistency
 Difficulty in accessing data
 Data isolation
 Integrity problems
 Atomicity problems
 Security Problems

DBMS File System


DBMS is a collection of data. In DBMS, File system is a collection of data. In this
the user is not required to write the system, the user has to write the procedures for
procedures. managing the database.
Helps to easily store, retrieve and Helps to store a collection of raw data files into the
manipulate data in a database hard disk
DBMS gives an abstract view of data File system provides the detail of the data
that hides the details. representation and storage of data.
DBMS provides a crash recovery File system doesn't have a crash mechanism, i.e.,
mechanism, i.e., DBMS protects the user if the system crashes while entering some
from the system failure. data, then the content of the file will lost.
DBMS provides a good protection It is very difficult to protect a file under the file
mechanism. system.
DBMS provides higher data consistency It has data inconsistency
using normalization
DBMS contains a wide variety of
File system can't efficiently store and retrieve the
sophisticated techniques to store and
data.
retrieve the data.
DBMS takes care of Concurrent access of In the File system, concurrent access has many
data using some form of locking. problems like redirecting the file while other
deleting some information or updating some
information.
Ex: MySQL, MSSQL, Oracle, DB2 Ex: NFTS and Ext

ADVANTAGES OF A DBMS:

Using a DBMS to manage data has many advantages:

Data independence:
Application programs should be as independent as possible from details of data
representation and storage. The DBMS can provide an abstract view of the data to
insulate application code from such details.

Efficient data access:


A DBMS utilizes a variety of sophisticated techniques to store and retrieve data efficiently.

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


Data integrity and security:
If data is always accessed through the DBMS, the DBMS can enforce integrity
constraints on the data before being accessed. Also, the DBMS can enforce access
controls that govern what data is visible to different classes of users.
Data administration:
When several users share the data, centralized data administration can be done effectively
with DBMS.
Concurrent access and crash recovery:
A DBMS schedules concurrent accesses to the data in such a manner that users can think
of the data as being accessed by only one user at a time. Further, the DBMS protects
users from the effects of system failures.
Reduced application development time:
Clearly, the DBMS supports many important functions that are common to many
applications accessing data stored in the DBMS. This, in conjunction with the high-level
interface to the data, facilitates quick development of applications.
1.2 DATA MODEL
A Database model(or Data base model) defines the logical design and structure of a
database. Data Models are fundamental entities to introduce abstraction in a DBMS. It
defines how data will be stored, accessed and updated in a database management system.

While the Relational Model is the most widely used database model, there are other models too:
 Hierarchical Model
 Network Model
 Entity-relationship Model
 Relational Model
 Object Oriented Data Base Model
1.2.1 Hierarchical Model
This database 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.
 In this model, a child node will have a single parent node.
 This model efficiently describes many real-world relationships.
 Hierarchical model represents tree-like structure with one one-to-many relationship
between two different types of data, for example, one department can have many
courses, many professors and many students.
Advantages:
College
 Simplicity: The design is simple and
more logical.
 Data Integrity: The data can Department Infrastructure
always be referred to the parent data
for integrity. Course Teachers Students
Fig.1.1 Hierarchical Model
B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)
Disadvantages:
 Searching for data requires the DBMS to run through the entire model from top to
bottom until the required information is found, making queries very slow.
 This model support only one-to-many relationships, many-to-many relationships are
not supported.
1.2.2 Network Model
 Network Database Model organizes the data using Graph like structures. It allows a
record to have more than one parent.
 In this database model, data is more related as more relationships are established in
this model. Hence accessing the data is also easier and faster. 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.
Advantage
College
• The network model is conceptually simple and
easy to design.
• The network model can handle the one to many Department Infrastructure
and many to many relationships.
• The data access is easier and flexible than the
hierarchical model. Students
• The network model is better than the
hierarchical model in isolating the programs Fig. 1.2 Network Model
from the complex physical storage details
Disadvantage:
• All the records are maintained using pointers and hence the whole database
structure becomes very complex.
• The insertion, deletion and updating operations of any record require the large
number of pointers adjustments.
• The structural changes to the database are very difficult.

1.2.3Entity-relationship Model

 This model is useful in developing a conceptual design for the database.


 Entity Relationship model is based on –
Entity – These are representation of a real world entities in code.
Attributes – These are the characteristic properties of entities
Relationship – Logical relationship between various entities involved in the
Database creation.
 One to one
 One to many
 Many to one
 Many to many

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


2 In this database model, relationships are created by dividing object of interest into entity and
its characteristics into attributes.
E-R Models(semantic data model) model used to pictorially denote entities and the
 relationships among them.
 The attribute values that describe each entity become a major part of the data stored
in the database.
 It is very simple and easy to design logical view of data.
In this diagram,
 Rectangle represents the entities. Eg. Doctor and Patient.
 Ellipse represents the attributes. Eg. DocId, Dname, PId, Pname.
 Diamond represents the relationship in ER diagrams. Eg. Doctor diagnoses the Patient.

1.2.4 Relational Model

 In this model, data is organised in two-dimensional tables and the relationship is


maintained by storing a common field.
 This model was introduced by E.F Codd in 1970, and since then it has been the most
widely used database model.
 The basic structure of data in the relational model is tables. Hence, tables are also known as
relations in relational model.
 In relational model, three key terms are heavily used such as relations, attributes, and
domains. A relation nothing but is a table with rows and columns. The named
columns of the relation are called as attributes, and finally the domain(synonym -
Data type) is nothing but the set of values the
attributes can take eid ename salary age
Advantages: 22 Abi 10000 25.0
 Simple: This model is more simple as compared to the
network and hierarchical model. 31 Bob 25000 35.5
 Scalable: This model can be easily scaled as we can add
as many rows and columns we want. 58 Akhil 45000 35.0
 The relational database supports both data
independence and structure independence concept which makes the database design,
maintenance, administration and usage much easier than the other models.
 It is easier to maintain security as compared to other models.
Disadvantages:
Hardware Overheads: For hiding the complexities and making things easier for the
user this model requires more powerful hardware computers and data storage devices.
Bad Design: As the relational model is very easy to design and use. So the users don't
need to know how the data is stored in order to access it. This ease of design can lead
to the development of a poor database which would slow down if the database grows.

1.2.5 Object Oriented Data Model

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


• The real-world problems are more closely represented through the object-oriented
data model.
• In this model, both the data and relationship are present in a single structure known
as an object. In this model, two are more objects are connected through links. We
use this link to relate one object to other objects.

The object-oriented data model is based on the object-oriented- programming language


concept, which is now in wide use.
• Inheritance, polymorphism, overloading. object-identity, encapsulation and
information hiding with methods to provide an interface to objects, are among the key
concepts of object-oriented programming that have found applications in data modeling.
• The following figure shows the difference between relation and object-oriented
database model.

Fig:1.6 Relation vs Object Oriented database model


Advantages

• Object-oriented databases can handle the different types of data, for example, pictures,
voice video, including text, numbers and so on.
• Object-oriented databases provide us code reusability, real world modelling, and
improved reliability and flexibility.
• The object-oriented database is having low maintenance costs because most of the

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


tasks within the system are encapsulated.

LEVELS OF ABSTRACTION

Data abstraction is a process of hiding the implement details (such as how the data are
stored and maintained) and representing only the essential features to simplify user's
interaction with the system.
The major purpose of a database system is to provide users with an abstract view of the
system. The database description consists of a schema at each of these three levels of
abstraction as shown in fig 1.7:

 Conceptual schema
 Physical schema
 External schema
A physical schema can be defined as the design of a database at its physical level. In this
level, it is expressed how data is stored in blocks of storage.
The process of arriving at a good physical schema is called physical database design.

A logical schema can be defined as the design of the database at its logical level. In this
level, the programmers as well as the database administrator (DBA) work. At this level,
data can be described as certain types of data records which can be stored in the form of
data structures. However, the internal details (such as an implementation of data
structure) will be remaining hidden at this level.
The process of arriving at a good conceptual schema is called conceptual database design

View schema can be defined as the design of the database at view level which
generally describes end-user interaction with database systems.
 Highest level of abstraction.
 Describes only part of the database for a particular group of users.
 Can provide many different views of a database.

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


Fig 1.7 Levels Of Abstraction in DBMS
Type of Schema Implementation
External Schema View 1: Course info(cid:int,cname:string)
View 2: studeninfo(id:int. name:string)
Conceptual Shema Students(id: int, name: string, login: string, age: integer)
Courses(id: int, cname.string, credits:integer)
Enrolled(id: int, grade:string)
Physical Schema  Relations stored as unordered files.
 Index on the first column of Students.

DATA INDEPENDENCE
Data independence refers characteristic of being able to modify the schema at one level
of the database system without altering the schema at the next higher level.
Data independence is achieved through use of the three levels of data abstraction;
There are two types of data independence:
Logical Data Independence
 Logical data independence refers characteristic of being able to change the
conceptual schema without having to change the external schema.
 Logical data independence is used to separate the external level from the conceptual view.
 If we do any changes in the conceptual view of the data, then the user view of
the data would not be affected.
 Logical data independence occurs at the user interface level.
Physical Data Independence
 Physical data independence can be defined as the capacity to change the internal
schema without having to change the conceptual schema.
 If we do any changes in the storage size of the database system server, then the
Conceptual structure of the database will not be affected.
 Physical data independence is used to separate conceptual levels from the internal levels.
 Physical data independence occurs at the logical interface level.

STRUCTURE OF A DBMS
The DBMS accepts SQL commands generated from a variety of user interfaces,
produces query evaluation plans, executes these plans against the database, and returns
the answers.

Figure 1.8 shows the structure of a typical DBMS based on the relational data model.\
Query Evaluation Engine consists of the following components:
 Parser: The query parser breaks the query into tokens. It also ensures that the

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


query is syntactically and semantically correct. If the query does not have any
errors, then it is converted into an algebraic expression and passes it to the next
step.
 Operator Evaluation: Operators in the query is evaluated using several
alternative techniques such as Iteration techniques, Indexing techniques and
partitioning techniques.
 Optimizer: is responsible to produce the query evaluation plan which gives the
most effective way to execute the user request
 Execution Engine: Finally executes the query as per query evaluation plan and
display the required result.
Files and access methods: It is responsible for the abstraction of file structures stored and
for creating indexes on the files for fast access.
Buffer Manager: It is responsible to bring pages in and out from disk to main memory.
Disk space manager: It manages the space on the disk by providing empty space
for new requests, deleting space allocated for existing files which are deleted by users.

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


Concurrency control is achieved by:
Transaction manager: It ensures that transactions request and release locks
according to a suitable locking protocol and schedules the execution transactions.
Lock manager: It keeps track of requests for locks and grants locks on database
objects when they become available.
Recovery manager: It is responsible for maintaining a log, and restoring the system to a
consistent state after a crash.
System Catalog (Data Dictionary): It contains all the information about the database. As
the name suggests, it is the dictionary of all the data items. It contains description of all
the tables, view, data files, indexes, triggers etc.

INTRODUCTION TO DATABASE DESIGN


Database design process can be divided into six steps

Requirements Analysis
 Requirements Analysis is the process of determining what the database is to be used for.
 It involves interviews with user groups and other stakeholders to identify
what functionality they require from the database, what kinds of data they
wish to process and the most frequently performed operations.
 This discussion is at a non-technical level and enables the database
designers to understand the business logic behind the desired database.
 Gathered information is organized and presented using suitable tools.
Conceptual database design:
 Once the information is gathered in the requirements analysis step, a
conceptual database design is developed. This step is often carried out
using the ER model, or a similar high-level data model.
 The ER Model is used to create a simple description of the data that

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


matches both how users and developers think of the data by identifying
entities, relationship between them, attributes and integrity constraints.

Logical Database Design:


In this step, the conceptual database design of a database schema is
converted into logical data base design.
 That is logical data base design involves translating the ER diagrams into
actual relational database schema
Schema Refinement:
 The fourth step in data base design is to analyze the collection of relations
in our relational database schema to identify the feature problems such as
redundancies, anomalies, etc., , and to refine it.
Physical Database Design:
 In this step, the physical features of the database which includes form of
file organization and the internal storage structure are specified.
 This step may simply involve building indexes on some tables and
clustering some tables, or it may involve redesign of parts of the database
schema obtained from the earlier design steps.
Application and Security Design :
 Any soft ware project that involves a DBMS must consider applications
that involve processes and identify the entities. Example: Users, User
groups, departments, etc,.
 We must describe the role of each entity in every process. As a Security
design, for each role, we must identify the parts of the database that must
be accessible and the parts of the database that must not be accessible by
enforcing access rules.
ENTITIES, ATTRIBUTES AND ENTITY SETS ENTITY
An entity refers to an object in the real world that is distinguishable from other
objects. An entity is described (in database) using a set of attributes.
ENTITY SET: A collection of similar entities, e.g., all employees.

All entities in an entity set have the same set of attributes In ER diagram,
 Attributes describe the properties of entities in the entity set. (Eg. Attributes
of Employees entity are SSN, Name, Lot, etc.,
 Each attribute has a domain.
 Based on the values of certain attributes, an entity can be identified uniquely.
Types of Entity Sets-
An entity set may be of the following two types
1.strong entity set
2.weak entity set
Strong Entity Set

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


A strong entity set is an entity set that contains sufficient attributes to uniquely
identify all its entities. i.e) a primary key exists for a strong entity set.
Primary key of a strong entity set is represented by underlining it.

Weak Entity Set


 A weak entity set is an entity set that does not contain sufficient
attributes to uniquely identify its entities. i.e) a primary key does not
exist for a weak entity set.
 However, it contains a partial key called as a discriminator.

RELATIONSHIPS AND RELATIONSHIP SETS

A relationship is defined as an association among several entities.

Example- ‘ Works in’ is a relationship that exists between entities Employee and Department.

Employee Works_in Department

Relationship Set-

A relationship set is a set of relationships of same type

Example-

Set representation of above ER diagram is-

Degree of a Relationship Set-

The number of entity sets that participate in a relationship set is termed as the degree of that
relationship set. Thus, On the basis of degree of a relationship set, a relationship set can be classified
into the following types
Types of Relationship Sets-

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


Unary Relationship Set / Self Relationship set
 Binary Relationship Set
 Ternary Relationship Set
 N-ary Relationship Set

1.Unary Relationship Set-

An entity set can participate in a relationship set with itself. Entities in same set play different roles
in the relationship. Role indicators express the role
Example-

2.Binary Relationship Set –


Binary relationship set is a relationship set where two entity sets participate in a relationship set
Example- Employees works in Departments

3.Ternary Relationship Set-


Ternary relationship set is a relationship set where three entity sets participate in a relationship set.
Example-

 If Each department has offices in several locations


 We want to record the locations at which each employee works

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


Descriptive Attributes:
A relationship can also have some attributes, which are called as ‘descriptive
attributes. These are used to record information about the relationship.
Example:
James of ‘Employees’ entity set works in a department entity set since 1991.

4. N-ary Relationship Set-


N-ary relationship set is a relationship set where ‘n’ entity sets participate in a relationship set.
Instance:
An instance of a relationship set is a set of relationships. It is a snapshot of the relationship at
some instant of time

ADDITIONAL FEATURES OF ER MODEL


Key Constraint (Cardinality Constraint)
Cardinality is the number of entity instances to which another entity set can map
under the relationship
Types of Cardinality Ratios-
1.Many-to-Many cardinality (m:n)
A key constraint between an entity set S and a relationship set
2. Many-to-One cardinality (m:1) restricts instances of the relationship set by requiring that each
3. One-to-Many cardinality (1:n) entity of S participate in at most one relationship.
4. One-to-One cardinality (1:1)

1.Many-to-Many Cardinality-

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


By this cardinality constraint,
 An entity in set A can be associated with any number (zero or more) of entities in set B.
 An entity in set B can be associated with any number (zero or more) of entities in set A.
Example:

2.One-to-One Cardinality-

By this cardinality constraint,


 An entity in set A can be associated with at most one entity in set B.
 An entity in set B can be associated with at most one entity in set A.

Example-

Each employee can manage at most 1 department.

2.4.2.Participation Constraints:

• A participation constraint between an entity set S and a relationship set


specifies either each entity of an entity set must participate in at least one
relationship or not.
There are 2 types of participation constraints, which are as below.

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


1. Total Participation
2. Partial Participation
Total Participation
In total participation every entity in the entity set participates in at least one
relationship in the relationship set.

Example:

 Every department must have a manager. So “Departments” entity set has total
participation in Manages relationship
 Represented as thickened line (there is a key constraint as well)

2.Partial participation

 In partial participation some entities may not participate in any relationship in


the relationship set.
 It is indicated by single line.
Example:

 Not every department has a manager, So “Departments” entity set has partial participation

Weak Entity Set

Entity types that do not have key attributes of their own are called as weak entity types.
A weak entity set can be identified uniquely only by considering the primary key of another
(Identifying owner) owner
For any weak entity set, following restrictions must hold.
a. The owner entity set and the weak entity set must participate in a One-to-many

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


relationship set, which is called as the ‘Identifying Relationship Set’ of the weak
entity set.
b. The weak entity set must have total participation in the identifying relationship set.

Partial key(or discriminator) of the weak entity set:


The set of attributes of a weak entity set that uniquely identify a weak entity for a
given owner entity is called as ‘partial key of the weak entity set’.

Representation
Dark lines: to draw weak entity set & its identifying relationship set (with
one-many relationship constraint)
Broken line: to underline a partial key
Example:
‘Dependents’ is an example of a weak entity set which is uniquely identified by (ssn, pname)
‘dpname’ is a partial key for dependents. Policy: identifying relationship set

Class Hierarchies

Class hierarchies organize structurally similar entities through inheritance into


sub-and superclasses using ISA symbol.

• If we declare A ISA B, every A entity is also considered to be a B entity.

Reasons for using ISA:

• To add descriptive attributes specific to a subclass.


• To identify entities participating in a relationship.

Class Hierarchy Based On Sub-super Set Generalization

 Generalization is like a bottom-up approach in which two or

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


more entities of lower level combine to form a new entity at higher level if they have some
attributes in common
 i.e., In generalization, entities are combined to form a more generalized entity, i.e.,
subclasses are combined to make a superclass
Example: Hourly-Emps and Contract-Emps can be generalized and create a higher level entity
EMPLOYEE
Specialization :
 Specialization is a top-down approach in which one higher level entity can be
broken down into a set of lower level entities.
 It is the process of identifying the subsets of a superclass that share some special attributes.
 Normally, the superclass is defined first, the subclass and its related attributes
are defined next, and relationship set are then added.
Example: EMPLOYEE entity can be specialized as Hourly_Emps and Contract_Emps.
Class Hierarchy Based On Constraints
1. Overlap constraints(allowed/disallowed) : Overlap constraints determine whether two subclasses
are allowed to contain the same entity commonly

Example: Can John be both an Hourly_Emps entity and a Contract_Emps entity?...Disallowed


Can he be both a Contract_Emps entity and a Senior_Emps entity? ...Allowed
2.Covering Constraints(Yes/No) : Covering constraints determine whether all entities in the
superclass is collectively included in at least one of the subclasses.

Example: Should every Employee be a Hourly-Emps or Contract-Emps? ….. No.


•Does every hourly employee and contract employee are employees of this organization? …
Yes

Aggregation:
Aggregration is the process of transforming a relationship set into an entity set for the purpose

of relating the resulting construct to other entity sets.


It is used to model a relationship involving a
relationship set
Representation: dashed box
Example:
 Consider the constraint that each
sponsorship is monitored by at
most one employee
 Sponsors and Monitor
are two distinct
Relationships
 Here the relationship set Sponsors
can be treated as an entity set for the
purpose of relating it with Monitors
relationship set

CONCEPTUAL DESIGN USING THE ER MODEL

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


Design choices:
Developing an ER diagram presents several design issues, including the following:
 Should a concept be modeled as an entity or an attribute?
 Should a concept be modeled as an entity or a relationship?
 Identifying relationships: Binary or ternary? Aggregation?
Constraints in the ER Model:
 A lot of data semantics can (and should) be captured.
Entity vs Attribute
While identifying the attributes of an entity set, it is sometimes not clear whether a
property should be modeled as an attribute or as an entity set
Example:
 Should address be:
– attribute of Employees or an entity (related to Employees)?

Depends upon use of address information, and the semantics of the data:
 If several addresses per employee, address must be an entity (since attributes
cannot be set- valued).
 If structure (city, street, etc.) is important, address must be modeled as an entity
(since attribute values are atomic).
Entity vs Relationship
Works_In4 does not allow an employee to work in a department for two or
more periods

If wanting to record several working periods for an employee in Work_In4 Introduce new entity
set, Duration

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


Binary vs. Ternary Relationships
Constraints:
 An employee can own several policies. Each policy
can
be owned by several employee.
 Each dependent can be covered by several policies
o To specify the above given
constraints, ternary relationship is
suitable.
o But to specify the below given
constraints, this design is bad
design.
Constraints:
o Each policy is owned
by just 1 employee,
and,
o Dependents is a weak
entity set, and each
dependent is tied to the
covering policy
Better design
In this example: two
binary relationships are
better than one ternary
relationship to specify
the above given
constraint
Another example
The contract specifies
that a supplier will
supply some quantity of
a part to a department.
To specify this
constraint,
a ternary relationship is

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)


better than three binary
relationships

Example: University Database

• We have four entity sets: Professor, Project, Graduate, Department.

• Each project is managed by one professor (principal investigator)

• Professors can manage multiple projects.


• Each project is worked on by one or more professors (co-investigators).

• Professors can work on multiple projects.


• Each project is worked on by one or more graduate students.
• Graduate students can work on multiple projects.

• When graduate students work on multiple projects, they must have a


supervisor (prof) for each one.
• Departments have a professor who runs the department
• Professors work in one or more departments

• For each department a professor works in, a time percentage is associated with their job

• Graduate students have one major department in which they are working on their degree

• Each graduate student has another, more senior graduate student who
advises him or her on what courses to take

B. TECH – COMPUTER SCINCE AND ENGINEERING – GNITC (SPECIAL BATCH)

You might also like