0% found this document useful (0 votes)
108 views44 pages

ER Diagram

The document defines key concepts in entity-relationship modeling including entities, attributes, relationships, keys, and ER diagrams. It provides examples of different types of relationships (one-to-one, one-to-many, many-to-one, many-to-many) and keys (super key, candidate key, primary key, composite key, foreign key). ER diagrams use basic shapes to represent these concepts and show relationships between entities.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views44 pages

ER Diagram

The document defines key concepts in entity-relationship modeling including entities, attributes, relationships, keys, and ER diagrams. It provides examples of different types of relationships (one-to-one, one-to-many, many-to-one, many-to-many) and keys (super key, candidate key, primary key, composite key, foreign key). ER diagrams use basic shapes to represent these concepts and show relationships between entities.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 44

 ER Model is represented by means of an ER

diagram. Any object, for example, entities,


attributes of an entity, relationship sets, and
attributes of relationship sets, can be
represented with the help of an ER diagram.
 Entity-relationship model is a model used for
design and representation of relationships
between data.
 The main data objects are termed as Entities,
with their details defined as attributes, some of
these attributes are important and are used to
identity the entity, and different entities are
related using relationships.
 If the attribute roll no. can uniquely identify a
student entity, amongst all the students, then
the attribute roll no. will be said to be a key.
Following are the types of Keys:
 Super Key
 Candidate Key
 Primary Key
 Composite Key
 Foreign Key
 A super key is a set of one or more attributes
(columns), which can uniquely identify a row
in a table.
 Table: Employee

Emp_SSN Emp_Number Emp_Name


123456789 226 Steve
999999321 227 Ajeet
888997212 228 Chaitanya
777778888 229 Robert
  The above table has following super keys. All
of the following sets of super key are able to
uniquely identify a row of the employee table.
 {Emp_SSN}
 {Emp_Number}
 {Emp_SSN, Emp_Number}
 {Emp_SSN, Emp_Name}
 {Emp_SSN, Emp_Number, Emp_Name}
 {Emp_Number, Emp_Name}
A candidate key is a minimal super key with no
redundant attributes. The following two set of
super keys are chosen from the above sets as
there are no redundant attributes in these sets.
 {Emp_SSN}
 {Emp_Number}
 A primary key is a field in a table which
uniquely identifies each row/record in a
database table. Primary keys must contain
unique values.
 A primary key column cannot have NULL
values.
 A table can have only one primary key, which
may consist of single or multiple fields. When
multiple fields are used as a primary key, they
are called a composite key.
 A key that has more than one attributes is
known as composite key. It is also known as
compound key.
 A primary key having two or more attributes is
called composite key. It is a combination of
two or more columns.
 Lets consider a table Sales. This table has four
columns (attributes) – cust_Id, order_Id,
product_code & product_count.
cust_Id order_Id product_code product_count
C01 O001 P007 23
C02 O123 P007 19
C02 O123 P230 82
C01 O001 P890 42
 Column cust_Id alone cannot become a key as a same
customer can place multiple orders, thus the same customer
can have multiple entires.
 Column order_Id alone cannot be a primary key as a same
order can contain the order of multiple products, thus same
order_Id can be present multiple times.
 Column product_code cannot be a primary key as more
than one customers can place order for the same product.
 Column product_count alone cannot be a primary key
because two orders can be placed for the same product
count.
 Based on this, it is safe to assume that the key should be
having more than one attributes:
Key in above table: {cust_id, product_code}
 A Foreign Key creates a link between tables. It
references the primary key in another table and
links it.
 For example, the DeptID in the Employee table
is a foreign key −
 <Employee>
EmpID EmpName EmpAge DeptID

 <Department>
DeptID DeptName DeptZone
 When an Entity is related to another Entity,
they are said to have a relationship. For
example, A Class Entity is related
to Student entity, because students study in
classes,
 Depending upon the number of entities
involved, a degree is assigned to relationships.
 Entities are represented by means of
rectangles. Rectangles are named with the
entity set they represent.
 An entity that cannot be uniquely identified by its
own attributes and relies on the relationship with
other entity is called weak entity. The weak entity
is represented by a double rectangle.
 For example – a bank account cannot be uniquely
identified without knowing the bank to which the
account belongs, so bank account is a weak entity.
 Attributes are the properties of entities.
Attributes are represented by means of ellipses.
Every ellipse represents one attribute and is
directly connected to its entity (rectangle).
 A key attribute can uniquely identify an entity
from an entity set. For example, student roll
number can uniquely identify a student from a
set of students. Key attribute is represented by
oval same as other attributes however the text
of key attribute is underlined.
 If the attributes are composite, they are further
divided in a tree like structure. Every node is
then connected to its attribute. That is,
composite attributes are represented by ellipses
that are connected with an ellipse.
 Multivalued attributes are depicted by double
ellipse
 One-to-One Relationships
 One-to-Many Relationships
 Many to One Relationships
 Many-to-Many Relationships
 One-to-one − One entity from entity set A can be
associated with at most one entity of entity set B and
vice versa.
 One-to-many − One entity from entity set A can be
associated with more than one entities of entity set B
however an entity from entity set B, can be associated
with at most one entity.
 Many-to-one − More than one entities from entity set
A can be associated with at most one entity of entity
set B, however an entity from entity set B can be
associated with more than one entity from entity set
A.
 Many-to-many − One entity from A can be
associated with more than one entity from B and vice
versa.
 For them problem statement we know that,
 A student can be assigned multiple courses
 A Professor can deliver only one course
 In the one-to-many relationship a loan is
associated with at most one customer via
borrower, a customer is associated with several
(including 0) loans via borrower
 In a many-to-one relationship a loan is
associated with several (including 0) customers
via borrower, a customer is associated with at
most one loan via borrower
 A customer is associated with several (possibly 0)
loans via borrower
 A loan is associated with several (possibly 0)
customers via borrower

You might also like