SlideShare a Scribd company logo
1 of 39
The Entity-Relationship Model
Databases Model the Real World 
• “Data Model” allows us to translate real world 
things into structures computers can store 
• Many models: Relational, E-R, O-O, Network, 
Hierarchical, etc. 
• Relational 
– Rows & Columns 
– Keys & Foreign Keys to link Relations
Conceptual Design 
• What are the entities and relationships in the 
enterprise? 
• What information about these entities and 
relationships should we store in the database? 
• What are the integrity constraints or business 
rules that hold? 
• A database `schema’ in the ER Model can be 
represented pictorially (ER diagrams). 
• Can map an ER diagram into a relational 
schema.
ER Model Basics 
name 
Employees 
ssn 
• Entity: Real-world object, distinguishable from 
other objects. An entity is described 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. 
– Each entity set has a key (underlined). 
– Each attribute has a domain. 
lot
ER Model Basics (Contd.) 
since 
• Relationship : Association among two or more 
entities. E.g., Attishoo works in Pharmacy 
department. 
– relationships can have their own attributes. 
• Relationship Set : Collection of similar relationships. 
– An n-ary relationship set R relates n entity sets E1 
... En 
; 
each relationship in R involves entities e1 
Î E1 
, ..., en 
Î En 
lot 
name 
Employees 
ssn 
Works_In 
dname 
did budget 
Departments
ER Model Basics (Cont.) 
lot 
name 
Employees 
ssn 
subor-dinate 
super-visor 
Reports_To 
since 
Works_In 
dname 
did budget 
Departments 
• Same entity set can participate in different 
relationship sets, or in different “roles” in 
the same set.
Relational definitions 
• A relation is a named, two-dimensional table 
of data 
• Every relation has a unique name, and 
consists of a set of named columns and an 
arbitrary number of unnamed rows 
• An attribute is a named column of a relation, 
and every attribute value is atomic. 
• Every row is unique, and corresponds to a 
record that contains data attributes for a 
single entity. 
• The order of the columns is irrelevant. 
• The order of the rows is irrelevant.
Relational structure 
• We can express the structure of a relation by 
a Tuple, a shorthand notation 
• The name of the relation is followed (in 
parentheses) by the names of the attributes 
of that relation, e.g.: 
• EMPLOYEE1(Emp_ID,Name,Dept,Salary)
Relational keys 
• Must be able to store and retrieve a row of 
data in a relation, based on the data values 
stored in that row 
• A primary key is an attribute (or combination 
of attributes) that uniquely identifies each 
row in a relation. 
• The primary key in the EMPLOYEE1 relation 
is EMP_ID (this is why it is underlined) as in: 
• EMPLOYEE1(Emp_ID,Name,Dept,Salary)
Composite and foreign keys 
A Composite key is a primary key that consists 
of more than one attribute. 
e.g., the primary key for the relation 
DEPENDENT would probably consist of the 
combination Emp-ID and Dependent_Name 
A Foreign key is used when we must 
represent the relationship between two 
tables and relations 
A foreign key is an attribute (possibly 
composite) in a relation of a database that 
serves as the primary key of another relation 
in the same database
Foreign keys 
Consider the following relations: 
EMPLOYEE1(Emp_ID,Name,Dept_Name,Salary) 
DEPARTMENT(Dept_Name,Location,Fax) 
The attribute Dept_Name is a foreign key in 
EMPLOYEE1. It allows the user to associate any 
employee with the department they are assigned 
to.
Removing multivalued attributes from 
tables 
• In the table, an entry at the intersection of each 
row and column is atomic (single-valued) - there 
can be no multivalued attributes in a relation, an 
example of this would be if each employee had 
taken more than one course, e.g.: 
Emp_ID Name Dept_Name Course 
A1 Fred Bloggs Info Sys Delphi 
VB
Removing multivalued attributes from 
tables 
To avoid this, we should create a new 
relation (EMPLOYEE2) which has a new 
instance for each course the employee 
has taken, e.g.: 
A1 Fred Bloggs Info Sys Delphi 
A1 Fred Bloggs Info Sys VB
Example database 
• The structure of the database is described 
by the use of a conceptual schema, which is 
a description of the overall logical structure 
of a database. There are two common 
methods for expressing a conceptual 
schema: 
• A) Short text statements, in which each 
relation is named and the names of its 
attributes follow in parentheses 
• B) A graphical representation, in which each 
relation is represented by a rectangle 
containing the attributes for the relation.
Expressing the conceptual schema 
• Text statements have the advantage of simplicity, 
whilst the graphical representation provides a 
better means of expressing referential integrity 
constraints (discussed later) 
• Here is a text description for four relations: 
• CUSTOMER(Customer_ID, Customer_Name, 
Address, City, State, Zip) 
• ORDER(Order_ID, Order_Date, Customer_ID) 
• ORDER_LINE(Order_ID, Product_ID, Quantity) 
• PRODUCT(Product_ID, Product_Description, 
Product_Finish, Standard_Price, On_Hand)
Expressing the conceptual schema 
• Note that the primary key for ORDER_LINE 
is a composite key consisting of the 
attributes Order_ID and Product_ID 
• Also, Customer_ID is a foreign key in the 
ORDER relation, allowing the user to 
associate an order with a customer 
• ORDER_LINE has two foreign keys, 
Order_ID and Product_ID, allowing the user 
to associate each line on an order with the 
relevant order and product 
• A graphical representation of this schema is 
shown in the following Fig.
Schema for four relations 
Primary Key 
Foreign Key (implements 1:M 
relationship between 
customer and order) 
Combined, these are a composite 
primary key (uniquely identifies 
the order line)…individually they 
are foreign keys (implement M:M 
relationship between order and 
product)
Integrity constraints 
• These help maintain the accuracy and integrity 
of the data in the database 
• Domain Constraints - a domain is the set of 
allowable values for an attribute. 
• Domain definition usually consists of 4 
components: domain name, meaning, data 
type, size (or length), allowable 
values/allowable range (if applicable) 
• Entity Integrity ensures that every relation has 
a primary key, and that all the data values for 
that primary key are valid. No primary key 
attribute may be null.
Entity integrity 
• In some cases a particular attribute cannot 
be assigned a data value, e.g. when there is 
no applicable data value or the value is not 
known when other values are assigned 
• In these situations we can assign a null 
value to an attribute (null signifies absence 
of a value) 
• But still primary key values cannot be null – 
the entity integrity rule states that “no 
primary key attribute (or component of a 
primary key attribute) may be null
Integrity constraints 
• A Referential Integrity constraint is a rule that 
maintains consistency among the rows of two 
relations – it states that any foreign key value (on the 
relation of the many side) MUST match a primary key 
value in the relation of the one side. (Or the foreign 
key can be null) 
• In the following Fig., an arrow has been drawn from 
each foreign key to its associated primary key. A 
referential integrity constraint must be defined for 
each of these arrows in the schema
Referential integrity constraints 
Referential integrity constraints are 
drawn via arrows from dependent to 
parent table
Referential integrity 
• How do you know if a foreign key is allowed 
to be null? 
• In this example, as each ORDER must have 
a CUSTOMER the foreign key of 
Customer_ID cannot be null on the ORDER 
relation 
• Whether a foreign key can be null must be 
specified as a property of the foreign key 
attribute when the database is designed
Referential integrity 
Whether foreign key can be null can be complex to 
model, e.g. what happens to order data if we 
choose to delete a customer who has submitted 
orders? We may want to see sales even though 
we do not care about the customer anymore. 3 
choices are possible: 
Restrict – don’t allow delete of “parent” side if 
related rows exist in “dependent” side, i.e. prohibit 
deletion of the customer until all associated orders 
are first deleted
Referential integrity 
Cascade – automatically delete “dependent” side 
rows that correspond with the “parent” side row to 
be deleted, i.e. delete the associated orders, in 
which case we lose not only the customer but also 
the sales history 
Set-to-Null – set the foreign key in the dependent 
side to null if deleting from the parent side - an 
exception that says although an order must have a 
customer_ID value when the order is created, 
Customer_ID can become null later if the 
associated customer is deleted [not allowed for 
weak entities]
Key Constraints 
An employee can 
work in many 
departments; a 
dept can have 
many 
employees. 
since 
Manages 
dname 
did budget 
Departments 
lot 
since 
Works_In 
name 
Many-to- 1-to Many 1-to-1 
Many 
ssn 
Employees 
In contrast, each dept 
has at most one 
manager, according 
to the key constraint 
on Manages.
A Database Schema 
Schema Owner 
Tables Indexes Procedures 
Views Constraints 
schema objects
Table
A Database with Multiple Tables 
Publishers Books Customers 
Authors Inventory Orders 
[1]
Table 
Customers
Field (Column) 
a field 
Customers
Record (Row) 
Customers 
a record
Primary Key 
Customers 
primary key field 
Primary key is a unique identifier of records in a table. 
Primary key values may be generated manually or automatically.
Primary Key 
primary key fields 
Roles (Performances) 
A primary key can consist of more than one field.
Foreign 
Key 
relationship child table 
foreign key field 
primary key field 
parent table 
Directors 
Movies
Relationship Types 
• One-to-one 
• One-to-many 
• Many-to-many
Data Types 
• Alphanumeric (Text, Memo) 
• Numeric (Number, Currency, etc.) 
• Date/Time 
• Boolean (Yes/No)
Ternary Relationships 
qty 
Parts Contract Departments 
Suppliers 
– S “can-supply” P, D “needs” P, and D “deals-with” S does 
not imply that D has agreed to buy P from S. 
– How do we record qty?
ISA (`is a’) Hierarchies 
 As in C++, or other PLs, 
attributes are inherited. 
 If we declare A ISA B, 
every A entity is also 
considered to be a B 
entity. 
• Overlap constraints : Can Simon be an Hourly_Emps as well as a 
Contract_Emps 
name 
ssn 
Employees 
lot 
hourly_wages 
ISA 
Hourly_Emps 
contractid 
hours_worked 
Contract_Emps entity? (Allowed/disallowed ) 
• Covering constraints : Does every Employees entity also have to 
be an Hourly_Emps or a Contract_Emps entity? (Yes/no) 
• Reasons for using ISA: 
– To add descriptive attributes specific to a subclass. 
• i.e. not appropriate for all entities in the superclass 
– To identify entities that participate in a particular relationship 
• i.e., not all superclass entities participate
Aggregation 
Used to model a 
relationship 
involving a 
relationship set. 
Allows us to treat a 
relationship set 
as an entity set 
for purposes of 
participation in 
(other) 
relationships. 
until 
name 
Employees 
Monitors 
lot 
ssn 
started_on 
dname 
since 
pid pbudget 
did budget 
Projects Sponsors Departments 
Aggregation vs. ternary relationship? 
 Monitors is a distinct relationship, 
with a descriptive attribute. 
 Also, can say that each sponsorship 
is monitored by at most one employee.

More Related Content

What's hot

Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship DiagramSiti Ismail
 
3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMSkoolkampus
 
Fundamentals of database system - Relational data model and relational datab...
Fundamentals of database system  - Relational data model and relational datab...Fundamentals of database system  - Relational data model and relational datab...
Fundamentals of database system - Relational data model and relational datab...Mustafa Kamel Mohammadi
 
Logical database design and the relational model(database)
Logical database design and the relational model(database)Logical database design and the relational model(database)
Logical database design and the relational model(database)welcometofacebook
 
The relational data model part[1]
The relational data model part[1]The relational data model part[1]
The relational data model part[1]Bashir Rezaie
 
The entity relationship model
The entity relationship modelThe entity relationship model
The entity relationship modelyash patel
 
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization TechniquesNishant Munjal
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model IntroductionNishant Munjal
 
How to Draw an Effective ER diagram
How to Draw an Effective ER diagramHow to Draw an Effective ER diagram
How to Draw an Effective ER diagramTech_MX
 
Ch 6 Logical D B Design
Ch 6  Logical D B  DesignCh 6  Logical D B  Design
Ch 6 Logical D B Designguest8fdbdd
 
D I T211 Chapter 3
D I T211    Chapter 3D I T211    Chapter 3
D I T211 Chapter 3askme
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relationalJafar Nesargi
 
Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)Mudasir Qazi
 
Basic database analysis(database)
Basic database analysis(database)Basic database analysis(database)
Basic database analysis(database)welcometofacebook
 
ER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMSER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMSRubal Sagwal
 

What's hot (20)

Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
 
Relational model
Relational modelRelational model
Relational model
 
3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMS
 
Fundamentals of database system - Relational data model and relational datab...
Fundamentals of database system  - Relational data model and relational datab...Fundamentals of database system  - Relational data model and relational datab...
Fundamentals of database system - Relational data model and relational datab...
 
Logical database design and the relational model(database)
Logical database design and the relational model(database)Logical database design and the relational model(database)
Logical database design and the relational model(database)
 
Entity relationship diagram
Entity relationship diagramEntity relationship diagram
Entity relationship diagram
 
The relational data model part[1]
The relational data model part[1]The relational data model part[1]
The relational data model part[1]
 
enhanced er diagram
enhanced er diagramenhanced er diagram
enhanced er diagram
 
The entity relationship model
The entity relationship modelThe entity relationship model
The entity relationship model
 
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization Techniques
 
Chapter 8
Chapter 8Chapter 8
Chapter 8
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
 
How to Draw an Effective ER diagram
How to Draw an Effective ER diagramHow to Draw an Effective ER diagram
How to Draw an Effective ER diagram
 
Ch 6 Logical D B Design
Ch 6  Logical D B  DesignCh 6  Logical D B  Design
Ch 6 Logical D B Design
 
D I T211 Chapter 3
D I T211    Chapter 3D I T211    Chapter 3
D I T211 Chapter 3
 
The Relational Model
The Relational ModelThe Relational Model
The Relational Model
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relational
 
Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)
 
Basic database analysis(database)
Basic database analysis(database)Basic database analysis(database)
Basic database analysis(database)
 
ER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMSER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMS
 

Viewers also liked

Viewers also liked (11)

hydrostatic equilibrium
hydrostatic equilibriumhydrostatic equilibrium
hydrostatic equilibrium
 
UTMHB_Oct2015_english
UTMHB_Oct2015_englishUTMHB_Oct2015_english
UTMHB_Oct2015_english
 
Smile&magento
Smile&magentoSmile&magento
Smile&magento
 
Gratis Website Maken MAASTRICHT
Gratis Website Maken MAASTRICHTGratis Website Maken MAASTRICHT
Gratis Website Maken MAASTRICHT
 
Photography tips
Photography tipsPhotography tips
Photography tips
 
Curriculuma 1. zikloa
Curriculuma 1. zikloaCurriculuma 1. zikloa
Curriculuma 1. zikloa
 
Portfolio
PortfolioPortfolio
Portfolio
 
hydrostatic equilibrium
hydrostatic equilibriumhydrostatic equilibrium
hydrostatic equilibrium
 
Trombocitopenia inmune
Trombocitopenia inmuneTrombocitopenia inmune
Trombocitopenia inmune
 
Smile mobile 2015
Smile mobile 2015Smile mobile 2015
Smile mobile 2015
 
Entrepreneurship
EntrepreneurshipEntrepreneurship
Entrepreneurship
 

Similar to ER Digramms by Harshal wagh

5. relational structure
5. relational structure5. relational structure
5. relational structurekhoahuy82
 
entityrelationshipmodel.pptx
entityrelationshipmodel.pptxentityrelationshipmodel.pptx
entityrelationshipmodel.pptxThangamaniR3
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship ModelSlideshare
 
Advance database system(part 5)
Advance database system(part 5)Advance database system(part 5)
Advance database system(part 5)Abdullah Khosa
 
Entityrelationshipmodel
EntityrelationshipmodelEntityrelationshipmodel
EntityrelationshipmodelEnes Bolfidan
 
ICT DBA3 09 0710 Model Data Objects.pdf
ICT DBA3 09 0710 Model Data Objects.pdfICT DBA3 09 0710 Model Data Objects.pdf
ICT DBA3 09 0710 Model Data Objects.pdfInfotech27
 
DATA MODEL PRESENTATION UNIT I-BCA I.pptx
DATA MODEL PRESENTATION UNIT I-BCA I.pptxDATA MODEL PRESENTATION UNIT I-BCA I.pptx
DATA MODEL PRESENTATION UNIT I-BCA I.pptxJasmineMichael1
 
Islamic University Previous Year Question Solution 2019 (ADBMS)
Islamic University Previous Year Question Solution 2019 (ADBMS)Islamic University Previous Year Question Solution 2019 (ADBMS)
Islamic University Previous Year Question Solution 2019 (ADBMS)Rakibul Hasan Pranto
 
18306_lec-2 (1).ppt
18306_lec-2 (1).ppt18306_lec-2 (1).ppt
18306_lec-2 (1).pptIshuIswarya3
 
Database normalization
Database normalizationDatabase normalization
Database normalizationEdward Blurock
 

Similar to ER Digramms by Harshal wagh (20)

5. relational structure
5. relational structure5. relational structure
5. relational structure
 
entityrelationshipmodel.pptx
entityrelationshipmodel.pptxentityrelationshipmodel.pptx
entityrelationshipmodel.pptx
 
Revision ch 3
Revision ch 3Revision ch 3
Revision ch 3
 
DBMS Class 3
DBMS Class 3DBMS Class 3
DBMS Class 3
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
 
Advance database system(part 5)
Advance database system(part 5)Advance database system(part 5)
Advance database system(part 5)
 
Entityrelationshipmodel
EntityrelationshipmodelEntityrelationshipmodel
Entityrelationshipmodel
 
ICT DBA3 09 0710 Model Data Objects.pdf
ICT DBA3 09 0710 Model Data Objects.pdfICT DBA3 09 0710 Model Data Objects.pdf
ICT DBA3 09 0710 Model Data Objects.pdf
 
DATA MODEL PRESENTATION UNIT I-BCA I.pptx
DATA MODEL PRESENTATION UNIT I-BCA I.pptxDATA MODEL PRESENTATION UNIT I-BCA I.pptx
DATA MODEL PRESENTATION UNIT I-BCA I.pptx
 
Islamic University Previous Year Question Solution 2019 (ADBMS)
Islamic University Previous Year Question Solution 2019 (ADBMS)Islamic University Previous Year Question Solution 2019 (ADBMS)
Islamic University Previous Year Question Solution 2019 (ADBMS)
 
Datastage database design and data modeling ppt 4
Datastage database design and data modeling ppt 4Datastage database design and data modeling ppt 4
Datastage database design and data modeling ppt 4
 
18306_lec-2 (1).ppt
18306_lec-2 (1).ppt18306_lec-2 (1).ppt
18306_lec-2 (1).ppt
 
Database design
Database designDatabase design
Database design
 
ER modeling
ER modelingER modeling
ER modeling
 
T-SQL Overview
T-SQL OverviewT-SQL Overview
T-SQL Overview
 
DATABASE-1.pptx
DATABASE-1.pptxDATABASE-1.pptx
DATABASE-1.pptx
 
Database normalization
Database normalizationDatabase normalization
Database normalization
 
Data Models.pptx
Data Models.pptxData Models.pptx
Data Models.pptx
 
DATABASE DESIGN.pptx
DATABASE DESIGN.pptxDATABASE DESIGN.pptx
DATABASE DESIGN.pptx
 
Relational model
Relational modelRelational model
Relational model
 

Recently uploaded

Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........LeaCamillePacle
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxLigayaBacuel1
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayMakMakNepo
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 

Recently uploaded (20)

9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up Friday
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 

ER Digramms by Harshal wagh

  • 2. Databases Model the Real World • “Data Model” allows us to translate real world things into structures computers can store • Many models: Relational, E-R, O-O, Network, Hierarchical, etc. • Relational – Rows & Columns – Keys & Foreign Keys to link Relations
  • 3. Conceptual Design • What are the entities and relationships in the enterprise? • What information about these entities and relationships should we store in the database? • What are the integrity constraints or business rules that hold? • A database `schema’ in the ER Model can be represented pictorially (ER diagrams). • Can map an ER diagram into a relational schema.
  • 4. ER Model Basics name Employees ssn • Entity: Real-world object, distinguishable from other objects. An entity is described 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. – Each entity set has a key (underlined). – Each attribute has a domain. lot
  • 5. ER Model Basics (Contd.) since • Relationship : Association among two or more entities. E.g., Attishoo works in Pharmacy department. – relationships can have their own attributes. • Relationship Set : Collection of similar relationships. – An n-ary relationship set R relates n entity sets E1 ... En ; each relationship in R involves entities e1 Î E1 , ..., en Î En lot name Employees ssn Works_In dname did budget Departments
  • 6. ER Model Basics (Cont.) lot name Employees ssn subor-dinate super-visor Reports_To since Works_In dname did budget Departments • Same entity set can participate in different relationship sets, or in different “roles” in the same set.
  • 7. Relational definitions • A relation is a named, two-dimensional table of data • Every relation has a unique name, and consists of a set of named columns and an arbitrary number of unnamed rows • An attribute is a named column of a relation, and every attribute value is atomic. • Every row is unique, and corresponds to a record that contains data attributes for a single entity. • The order of the columns is irrelevant. • The order of the rows is irrelevant.
  • 8. Relational structure • We can express the structure of a relation by a Tuple, a shorthand notation • The name of the relation is followed (in parentheses) by the names of the attributes of that relation, e.g.: • EMPLOYEE1(Emp_ID,Name,Dept,Salary)
  • 9. Relational keys • Must be able to store and retrieve a row of data in a relation, based on the data values stored in that row • A primary key is an attribute (or combination of attributes) that uniquely identifies each row in a relation. • The primary key in the EMPLOYEE1 relation is EMP_ID (this is why it is underlined) as in: • EMPLOYEE1(Emp_ID,Name,Dept,Salary)
  • 10. Composite and foreign keys A Composite key is a primary key that consists of more than one attribute. e.g., the primary key for the relation DEPENDENT would probably consist of the combination Emp-ID and Dependent_Name A Foreign key is used when we must represent the relationship between two tables and relations A foreign key is an attribute (possibly composite) in a relation of a database that serves as the primary key of another relation in the same database
  • 11. Foreign keys Consider the following relations: EMPLOYEE1(Emp_ID,Name,Dept_Name,Salary) DEPARTMENT(Dept_Name,Location,Fax) The attribute Dept_Name is a foreign key in EMPLOYEE1. It allows the user to associate any employee with the department they are assigned to.
  • 12. Removing multivalued attributes from tables • In the table, an entry at the intersection of each row and column is atomic (single-valued) - there can be no multivalued attributes in a relation, an example of this would be if each employee had taken more than one course, e.g.: Emp_ID Name Dept_Name Course A1 Fred Bloggs Info Sys Delphi VB
  • 13. Removing multivalued attributes from tables To avoid this, we should create a new relation (EMPLOYEE2) which has a new instance for each course the employee has taken, e.g.: A1 Fred Bloggs Info Sys Delphi A1 Fred Bloggs Info Sys VB
  • 14. Example database • The structure of the database is described by the use of a conceptual schema, which is a description of the overall logical structure of a database. There are two common methods for expressing a conceptual schema: • A) Short text statements, in which each relation is named and the names of its attributes follow in parentheses • B) A graphical representation, in which each relation is represented by a rectangle containing the attributes for the relation.
  • 15. Expressing the conceptual schema • Text statements have the advantage of simplicity, whilst the graphical representation provides a better means of expressing referential integrity constraints (discussed later) • Here is a text description for four relations: • CUSTOMER(Customer_ID, Customer_Name, Address, City, State, Zip) • ORDER(Order_ID, Order_Date, Customer_ID) • ORDER_LINE(Order_ID, Product_ID, Quantity) • PRODUCT(Product_ID, Product_Description, Product_Finish, Standard_Price, On_Hand)
  • 16. Expressing the conceptual schema • Note that the primary key for ORDER_LINE is a composite key consisting of the attributes Order_ID and Product_ID • Also, Customer_ID is a foreign key in the ORDER relation, allowing the user to associate an order with a customer • ORDER_LINE has two foreign keys, Order_ID and Product_ID, allowing the user to associate each line on an order with the relevant order and product • A graphical representation of this schema is shown in the following Fig.
  • 17. Schema for four relations Primary Key Foreign Key (implements 1:M relationship between customer and order) Combined, these are a composite primary key (uniquely identifies the order line)…individually they are foreign keys (implement M:M relationship between order and product)
  • 18. Integrity constraints • These help maintain the accuracy and integrity of the data in the database • Domain Constraints - a domain is the set of allowable values for an attribute. • Domain definition usually consists of 4 components: domain name, meaning, data type, size (or length), allowable values/allowable range (if applicable) • Entity Integrity ensures that every relation has a primary key, and that all the data values for that primary key are valid. No primary key attribute may be null.
  • 19. Entity integrity • In some cases a particular attribute cannot be assigned a data value, e.g. when there is no applicable data value or the value is not known when other values are assigned • In these situations we can assign a null value to an attribute (null signifies absence of a value) • But still primary key values cannot be null – the entity integrity rule states that “no primary key attribute (or component of a primary key attribute) may be null
  • 20. Integrity constraints • A Referential Integrity constraint is a rule that maintains consistency among the rows of two relations – it states that any foreign key value (on the relation of the many side) MUST match a primary key value in the relation of the one side. (Or the foreign key can be null) • In the following Fig., an arrow has been drawn from each foreign key to its associated primary key. A referential integrity constraint must be defined for each of these arrows in the schema
  • 21. Referential integrity constraints Referential integrity constraints are drawn via arrows from dependent to parent table
  • 22. Referential integrity • How do you know if a foreign key is allowed to be null? • In this example, as each ORDER must have a CUSTOMER the foreign key of Customer_ID cannot be null on the ORDER relation • Whether a foreign key can be null must be specified as a property of the foreign key attribute when the database is designed
  • 23. Referential integrity Whether foreign key can be null can be complex to model, e.g. what happens to order data if we choose to delete a customer who has submitted orders? We may want to see sales even though we do not care about the customer anymore. 3 choices are possible: Restrict – don’t allow delete of “parent” side if related rows exist in “dependent” side, i.e. prohibit deletion of the customer until all associated orders are first deleted
  • 24. Referential integrity Cascade – automatically delete “dependent” side rows that correspond with the “parent” side row to be deleted, i.e. delete the associated orders, in which case we lose not only the customer but also the sales history Set-to-Null – set the foreign key in the dependent side to null if deleting from the parent side - an exception that says although an order must have a customer_ID value when the order is created, Customer_ID can become null later if the associated customer is deleted [not allowed for weak entities]
  • 25. Key Constraints An employee can work in many departments; a dept can have many employees. since Manages dname did budget Departments lot since Works_In name Many-to- 1-to Many 1-to-1 Many ssn Employees In contrast, each dept has at most one manager, according to the key constraint on Manages.
  • 26. A Database Schema Schema Owner Tables Indexes Procedures Views Constraints schema objects
  • 27. Table
  • 28. A Database with Multiple Tables Publishers Books Customers Authors Inventory Orders [1]
  • 30. Field (Column) a field Customers
  • 32. Primary Key Customers primary key field Primary key is a unique identifier of records in a table. Primary key values may be generated manually or automatically.
  • 33. Primary Key primary key fields Roles (Performances) A primary key can consist of more than one field.
  • 34. Foreign Key relationship child table foreign key field primary key field parent table Directors Movies
  • 35. Relationship Types • One-to-one • One-to-many • Many-to-many
  • 36. Data Types • Alphanumeric (Text, Memo) • Numeric (Number, Currency, etc.) • Date/Time • Boolean (Yes/No)
  • 37. Ternary Relationships qty Parts Contract Departments Suppliers – S “can-supply” P, D “needs” P, and D “deals-with” S does not imply that D has agreed to buy P from S. – How do we record qty?
  • 38. ISA (`is a’) Hierarchies As in C++, or other PLs, attributes are inherited. If we declare A ISA B, every A entity is also considered to be a B entity. • Overlap constraints : Can Simon be an Hourly_Emps as well as a Contract_Emps name ssn Employees lot hourly_wages ISA Hourly_Emps contractid hours_worked Contract_Emps entity? (Allowed/disallowed ) • Covering constraints : Does every Employees entity also have to be an Hourly_Emps or a Contract_Emps entity? (Yes/no) • Reasons for using ISA: – To add descriptive attributes specific to a subclass. • i.e. not appropriate for all entities in the superclass – To identify entities that participate in a particular relationship • i.e., not all superclass entities participate
  • 39. Aggregation Used to model a relationship involving a relationship set. Allows us to treat a relationship set as an entity set for purposes of participation in (other) relationships. until name Employees Monitors lot ssn started_on dname since pid pbudget did budget Projects Sponsors Departments Aggregation vs. ternary relationship? Monitors is a distinct relationship, with a descriptive attribute. Also, can say that each sponsorship is monitored by at most one employee.

Editor's Notes

  1. The slides for this text are organized into several modules. Each lecture contains about enough material for a 1.25 hour class period. (The time estimate is very approximate--it will vary with the instructor, and lectures also differ in length; so use this as a rough guideline.) This covers Lectures 1 and 2 (of 7) in Module (5). Module (1): Introduction (DBMS, Relational Model) Module (2): Storage and File Organizations (Disks, Buffering, Indexes) Module (3): Database Concepts (Relational Queries, DDL/ICs, Views and Security) Module (4): Relational Implementation (Query Evaluation, Optimization) Module (5): Database Design (ER Model, Normalization, Physical Design, Tuning) Module (6): Transaction Processing (Concurrency Control, Recovery) Module (7): Advanced Topics
  2. The slides for this text are organized into several modules. Each lecture contains about enough material for a 1.25 hour class period. (The time estimate is very approximate--it will vary with the instructor, and lectures also differ in length; so use this as a rough guideline.) This covers Lectures 1 and 2 (of 6) in Module (5). Module (1): Introduction (DBMS, Relational Model) Module (2): Storage and File Organizations (Disks, Buffering, Indexes) Module (3): Database Concepts (Relational Queries, DDL/ICs, Views and Security) Module (4): Relational Implementation (Query Evaluation, Optimization) Module (5): Database Design (ER Model, Normalization, Physical Design, Tuning) Module (6): Transaction Processing (Concurrency Control, Recovery) Module (7): Advanced Topics