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

Unit-2 DBMS

Uploaded by

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

Unit-2 DBMS

Uploaded by

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

UNIT-2

Data Modelling Using Entity-Relationship


Model
Using High Level Conceptual Data Models for Database Design
Cont..
• The first step shown is requirements collection and analysis. During this step, the database designers
interview prospective database users to understand and document their data requirements.
• The result of this step is a concisely written set of users’ requirements. These requirements should be
specified in as detailed and complete a form as possible. In parallel with specifying the data requirements, it
is useful to specify the known functional requirements of the application.
• These consist of the user-defined operations (or transactions) that will be applied to the database, including
both retrievals and updates.
• Once the requirements have been collected and analyzed, the next step is to create a conceptual schema for
the database, using a high-level conceptual data model. This step is called conceptual design.
• Next the conceptual schema is transformed from the high-level data model into the implementation data
model. This step is called logical design or data model mapping;
• The last step is the physical design phase, during which the internal storage structures, file organizations,
indexes, access paths, and physical design parameters for the database files are specified
Example Database applications
What is an ER Diagram?

• An Entity Relationship Diagram (ER Diagram) pictorially explains the


relationship between entities to be stored in a database.
Fundamentally, the ER Diagram is a structural design of the database.
It acts as a framework created with specialized symbols for the
purpose of defining the relationship between the database entities.
ER diagram is created based on three principal components: entities,
attributes, and relationships.
• What is an ER Model?
• An Entity-Relationship Model represents the structure of the database
with the help of a diagram. ER Modelling is a systematic process to
design a database as it would require you to analyze all data
requirements before implementing your database.
• Why Use ER Diagrams in DBMS?
• ER Diagram helps you conceptualize the database and lets you know
which fields need to be embedded for a particular entity
• ER Diagram gives a better understanding of the information to be
stored in a database
• It reduces complexity and allows database designers to build
databases quickly
• It helps to describe elements using Entity-Relationship models
• It allows users to get a preview of the logical structure of the database
• Symbols Used in ER Diagrams
• Rectangles: This Entity Relationship Diagram symbol represents entity
types
• Ellipses: This symbol represents attributes
• Diamonds: This symbol represents relationship types
• Lines: It links attributes to entity types and entity types with other
relationship types
• Primary key: Here, it underlines the attributes
• Double Ellipses: Represents multi-valued attributes
Cont..
Components of ER Diagram

• You base an ER Diagram on three basic concepts:


• Entities
• Weak Entity
• Attributes
• Key Attribute
• Composite Attribute
• Multivalued Attribute
• Derived Attribute
• Relationships
• One-to-One Relationships
• One-to-Many Relationships
• Many-to-One Relationships
• Many-to-Many Relationships
An entity can be of two types :
Entities •Tangible Entity : Entities that exist in the real world physically.
Example: Person, car, etc.
•Intangible Entity : Entities that exist only logically and have no
physical existence. Example: Bank Account, etc.

• An entity can be either a living or non-living component.


• It showcases an entity as a rectangle in an ER diagram.
• For example, in a student study course, both the student and the
course are entities.
Entity Type
• It refers to the category that a particular entity belongs to.

• Example :
• A table named student in a university database.
• A table named employee in a company database.
• Note :
• The category of a particular entity in the relation in RDBMS is called the entity type.
• It is represented by the name of the table and its schema.
Entity Set
• An entity set is a collection or set of all entities of a particular entity type at
any point in time. The type of all the entities should be the same.

• Example :
• The collection of all the students from the student table at a
particular instant of time is an example of an entity set.
• The collection of all the employees from the employee table at a
particular instant of time is an example of an entity set.
Example
• Consider a table student as follows :Table Name : Student
Entity : Each row is an entity.
Example :

Entity Type : Each entity belongs to the student type. Hence, the type of
entity here is a student.
Entity Set : The complete data set of all entities is called entity set.
For the above table, the records with student id 1, 2, 3, 4 are the entity set.
Difference Table
Classification of Entities
• Strong Entity:
A strong entity is not dependent on any other entity in the schema.
• A strong entity will always have a primary key.
• Strong entities are represented by a single rectangle.
• The relationship of two strong entities is represented by a single diamond.
• Various strong entities, when combined together, create a strong entity set.
• Weak Entity:
A weak entity is dependent on a strong entity to ensure its existence.
• Unlike a strong entity, a weak entity does not have any primary key.
• It instead has a partial discriminator key. A weak entity is represented by a double
rectangle.
• The relation between one strong and one weak entity is represented by a double
diamond.
• This relationship is also known as identifying relationship.
Weak Entity: Example
Difference between Strong and Weak
Entity:
Attribute

• An attribute exhibits the properties of an entity.


• You can illustrate an attribute with an oval shape in an ER diagram.
Key Attribute

• Key attribute uniquely identifies an entity from an entity set.


• It underlines the text of a key attribute.
• For example: For a student entity, the roll number can uniquely
identify a student from a set of students.
Composite Attribute

• An attribute that is composed of several other attributes is known as a


composite attribute.
• An oval showcases the composite attribute, and the composite
attribute oval is further connected with other ovals.
Multivalued Attribute

• Some attributes can possess over one value, those attributes are
called multivalued attributes.
• The double oval shape is used to represent a multivalued attribute.
Derived Attribute

• An attribute that can be derived from other attributes of the entity is


known as a derived attribute.
• In the ER diagram, the dashed oval represents the derived attribute.
The Complete Entity Type Student with its
Attributes can be represented as:
Relationship

• A Relationship Type represents the association between entity types.


For example, ‘Enrolled in’ is a relationship type that exists between
entity type Student and Course.
• In ER diagram, the relationship type is represented by a diamond and
connecting the entities with lines.
Relationship

• The diamond shape showcases a relationship in the ER diagram.


• It depicts the relationship between two entities.
• In the example below, both the student and the course are entities,
and study is the relationship between them.
• A set of relationships of the same type is known as a relationship set.
• The following relationship set depicts S1 as enrolled in C2, S2 as
enrolled in C1, and S3 as registered in C3.
One-to-One Relationship

• When a single element of an entity is associated with a single element


of another entity, it is called a one-to-one relationship.
• For example, a student has only one identification card and an
identification card is given to one person.
One-to-Many Relationship

• When a single element of an entity is associated with more than one


element of another entity, it is called a one-to-many relationship
• For example, a customer can place many orders, but an order cannot
be placed by many customers.
Many-to-One Relationship

• When more than one element of an entity is related to a single


element of another entity, then it is called a many-to-one relationship.
• For example, students have to opt for a single course, but a course
can have many students.
Many-to-Many Relationship

• When more than one element of an entity is associated with more


than one element of another entity, this is called a many-to-many
relationship.
• For example, you can assign an employee to many projects and a
project can have many employees.
Structural Constraints
• Structural Constraints are also called Structural properties of a
database management system (DBMS).
• Cardinality Ratios or Mapping Cardinality and Participation
Constraints taken together are called Structural Constraints.
Cont…
• The Structural constraints are represented by Min-Max notation.
• This is a pair of numbers(m, n) that appear on the connecting line
between the entities and their relationships.
• The minimum number of times an entity can appear in a relation is
represented by m whereas, the maximum time it is available is
denoted by n.
• If m is 0 it signifies that the entity is participating in the relation
partially, whereas, if m is either greater than or equal to 1, it denotes
total participation of the entity.
(i)Mapping Cardinality or Cardinality Ratio
• It is expressed as the number of entities to which another entity can
be associated via a relationship set.
• For the binary relationship set there are entity set A and B then the
mapping cardinality can be one of the following −
• One-to-one
• One-to-many
• Many-to-one
• Many-to-many
(ii) Participation Constraints

Participate constraints are two types as mentioned below −


• Total participation
• Partial Participation
The participation constraints are explained in the diagram below −

Here, the customer to Loan is partial


participation and the loan to the
customer is total participation.
Total participation

• The participation of an entity set E in a relationship set R is said to be


total if every entity in E Participates in at least one relationship in R.
• For Example − Participation of loan in the relationship borrower is
total participation.
Partial Participation

• If only some of the entities in E participate in relationship R, then the


participation of E in R is said to be partial participation.
• For example − Participation of customers in the relationship borrower
is partial participation.
ER Diagram
Example:1
• Construct an E-R diagram for a car-insurance company whose
customers own one or more cars each. Each car has associated with it
zero to any number of recorded accidents.
Solution
Example:2
• Construct an E-R diagram for a hospital with a set of patients and a
set of medical doctors. Associate with each patient a log of the
various tests and examinations conducted.
Solution
Example:3
• Consider a database used to record the marks that students get in
different exams of different course offerings.
Solution

You might also like