entity-relationship model & diagram - penn state
TRANSCRIPT
![Page 1: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/1.jpg)
1/30/2005 1
IST 210 Entity-Relationship Model & Diagram
Todd S. BacastowIST 210: Organization of data
![Page 2: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/2.jpg)
1/30/2005 2
IST 210 Design Principles
The client has some vague idea of what he/she wants. YOUR task is to design a DB that represents these thoughts and onlythese thoughts.
![Page 3: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/3.jpg)
1/30/2005 3
IST 210 Data ModelingData modeling is a formalismEntity-Relationship Model (ER) Entity Relationship model:
a visual model attempts to capture the structure of data
![Page 4: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/4.jpg)
1/30/2005 4
IST 210 What is Visual Modeling?
Business Process
Order
Item
Ship via
Computer System
Visual Modeling is modeling using standard graphical notations
![Page 5: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/5.jpg)
1/30/2005 5
IST 210 Visual Modeling is a Communication Tool
Use visual modeling to capture business objects and logic
Use visual modeling to analyze and design your database
Copyright © 1997 by Rational Software Corporation
![Page 6: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/6.jpg)
1/30/2005 6
IST 210 Entity-Relationship (E-R) Modeling
Premises The real world consists of entitiesEntities in one enterprise are relatedDatabase model = relevant entities + relationships among them
Entities and relationships have attributes
![Page 7: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/7.jpg)
1/30/2005 7
IST 210 E-RFeatures
Relatively easy to model real-world Translates easily to relational data model
Basic ConceptsEntity sets Relationship sets Attributes
![Page 8: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/8.jpg)
1/30/2005 8
IST 210 EntitiesDefinition
Entityan object that is distinguishable from other objects.
a particular student, a particular book
Entity seta set of entities of the same type that share the same set of properties
students, books
![Page 9: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/9.jpg)
1/30/2005 9
IST 210 EntitiesExamples of these entity types are:
Person: employeestudentcustomersupplier
![Page 10: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/10.jpg)
1/30/2005 10
IST 210 Entity TypesPlace:
citystatecounty
Object: vehiclebuildingairplaneanimal
![Page 11: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/11.jpg)
1/30/2005 11
IST 210 Entity TypesEvent:
purchasesaleregistrationgame
Concept: accountcoursework groupdepartment
![Page 12: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/12.jpg)
1/30/2005 12
IST 210 Weak EntitiesWeak entities are entities, but with a difference---Weak entities only exist because some other entity exists. For example:
two entities employee and salary-historysalary-history is a weak entity the record of an employee’s salary history could only exist if a record of an employee also existsE.g., Joe Smith’s salary history wouldn’t make much sense if Joe Smith doesn’t exist in the data base.
![Page 13: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/13.jpg)
1/30/2005 13
IST 210 Finding EntitiesEntities are normally located through the various user views identified during analysisSearch for entities by:
looking for nounsfinding objects/things that have many instances (i.e., things stored in tables) have descriptive/defining properties (attributes)
![Page 14: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/14.jpg)
1/30/2005 14
IST 210 AttributesDefinition:
Attribute: a descriptive property possessed by all members of an entity set. Attribute set: the set of all attributes possessed by members of an entity set.
e.g., book = (author,title,publisher,barcode, etc.) e.g., student = (ID,surname,firstname,course, etc.) e.g., subject = (code,name,lecturer,timetable, etc.)
![Page 15: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/15.jpg)
1/30/2005 15
IST 210 AttributesProperties of Attributes
Domain - the seat of permitted values for each attribute Type:
data type simple vs. composite attributes single-valued vs. multivaluedderived vs. stored
![Page 16: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/16.jpg)
1/30/2005 16
IST 210 Simple & Composite AttributesSimple attributes cannot be decomposed without loss of meaning, e.g.,
Title: Mr., Ms., Mrs., Dr.
Composite attributes can be further decomposed without loss of meaning, e.g.,
Name: first name + last nameDate: day + month + yearAddress: street + city + state + zip
![Page 17: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/17.jpg)
1/30/2005 17
IST 210 Single-Valued AttributesSingle-valued attributes occur once only for each entity instance, e.g.
IDNameDepartment
![Page 18: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/18.jpg)
1/30/2005 18
IST 210 Multi-Valued AttributesMulti-valued attributes can occur more than once for the same entity instance; e.g.
Sports person playsHobbies person likesSkills person has achievedCourses person has takenDegrees person completed
![Page 19: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/19.jpg)
1/30/2005 19
IST 210 Stored & Derived AttributesA derived attribute is one that can be calculated from other stored data
not usually stored as an attribute occasionally stored to speed information/query requests when these occur frequently
Maybe shown on ERD as attribute name within a dashed-line ellipse
![Page 20: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/20.jpg)
1/30/2005 20
IST 210 RelationshipsRelationship: an association among 2 or more entities
E1: student - R: takes - E2: subject e.g. Sara Smith takes IST210
![Page 21: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/21.jpg)
1/30/2005 21
IST 210 Relationship setsRelationship set: a relation among entity sets:
e.g. (Smith,IST210) takesRelationship sets
have degree may have attributes e.g. final mark attribute for takesrelationship
![Page 22: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/22.jpg)
1/30/2005 22
IST 210 E-R DiagramEntity
Relationship
![Page 23: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/23.jpg)
1/30/2005 23
IST 210 Entity Relationship Diagram Symbols
The symbols used in an ERD are not standardised so -
diagrams may appear somewhat different depending upon who created themsymbols used for our purposes will follow the format
![Page 24: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/24.jpg)
1/30/2005 24
IST 210 Graphical Elements of the ER Diagram
Its components are: rectangles representing entity sets. ellipses representing attributes. diamonds representing relationship sets.
Relationship
• Customer Account
Entity
• Customers• Accounts
Attribute
• id• name
![Page 25: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/25.jpg)
1/30/2005 25
IST 210 Basic Symbols
![Page 26: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/26.jpg)
1/30/2005 26
IST 210 Relationship
STUDENT COURSETake
Connect two or more entity setsRepresented by diamondsThink of the “value” of a relationship set as a tableOne row for each list of entities, one from each set, that are connected by the relationship
![Page 27: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/27.jpg)
1/30/2005 27
IST 210 Finding RelationshipsOften represented by a Verballows answers to questions not available through individual entity types
DEPENDENTHasEMPLOYEE
Weak Entity
![Page 28: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/28.jpg)
1/30/2005 28
IST 210 Attributes & RelationshipsRelationship can have 1 or more attributes
depend on relationshipdo not belong to the entitiesfor example the date on which a course was completed belongs to the relationship rather than either of the participating entitiesshown in same way as entity attributes
![Page 29: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/29.jpg)
1/30/2005 29
IST 210 Multiplicity or Cardinality
![Page 30: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/30.jpg)
1/30/2005 30
IST 210 Cardinality Symbology
![Page 31: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/31.jpg)
1/30/2005 31
IST 210 One-to-One
![Page 32: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/32.jpg)
1/30/2005 32
IST 210 One-to-Many
![Page 33: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/33.jpg)
1/30/2005 33
IST 210 Many-to-Many
![Page 34: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/34.jpg)
1/30/2005 34
IST 210 Recursive
![Page 35: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/35.jpg)
1/30/2005 35
IST 210 Common ConstraintsKeys we will discuss nextSingle-value constraints must have a certain value
Null valueReferential integrity constraints “broken link to a web page”Domain constraints a negative account balanceGeneral constraints limits you set
![Page 36: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/36.jpg)
1/30/2005 36
IST 210 Keys
Primary key Foreign key Primary key
1 Wood Bob C Ist 357
2 Kent Chuck B Ist 115
3 Smith Jane A Ist 357
4 Boone Dan B Ist 357
ID Last First Grade Class
Student
Ist 357 48 Jones
Ist 115 120 Brower
Ist 20 120 Mennis
Name #Stud Instructor
Class
![Page 37: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/37.jpg)
1/30/2005 37
IST 210 KeysA key is a set of attributes whose values can belong to at most one entityIn E-R model, every E.S. must have a keyMore than one key: a set of attributes is the “designated” keyIn E-R diagrams: underline all attributed of the designated key
![Page 38: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/38.jpg)
1/30/2005 38
IST 210 A Multi-attribute Key
dept+number (e.g. IST 210) form a key for courses.Possibly, hours+room also forms a key. But we have not designated it as such.
![Page 39: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/39.jpg)
1/30/2005 39
IST 210 Weak Entities & KeysWeak entity sets:
Does not have a primary keyare meaningful only in the context of a relationship with an owning strong entity set
![Page 40: Entity-Relationship Model & Diagram - Penn State](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb4ae52e268c58cd5c722d/html5/thumbnails/40.jpg)
1/30/2005 40
IST 210 We Made it!