data modeling using e/r diagramming
DESCRIPTION
Data modeling using E/R diagramming. Why analyze data? Notation for E/R Entities with attributes Types of attributes Relationships Cardinality History / things evolve Total participation Weak entities Steen Jensen, autumn 2013. Why analyze data?. - PowerPoint PPT PresentationTRANSCRIPT
Data modeling using ER
Data modeling using E/R diagramming1Why analyze data?Notation for E/REntities with attributesTypes of attributesRelationships Cardinality History / things evolveTotal participationWeak entities
Steen Jensen, autumn 2013
Why analyze data?Insight in data - and structures of dataCreate a structure in unstructured data
Prior to designing a database as a part of the systems development process.2
Figure 3.1 from chapt. 3 in ElmasriER modelingER stands for entity relationship
ER modeling is a widely used technique for data analysis
Many notations (syntax) for ER diagramsDifferent books different notationsDiagrams can be drawn using Dia,Visio or a similar tool.3
Figure 3.23 from chapt. 3 in ElmasriEntities with attributesCharacteristics of an entityAn important thing in the world we modelEntities have attributes (data)Similar to a class in OOA, but has no methods / functionsNaming convention: noun, singular
Notation (this book)Entity: RectangleAttribute: Oval
Every instance of the entity must be uniqueIdentified by a key, one or more attributesNotation for keys: Underline the name of the attribute(s)
4
Figure 3.7 from chapt. 3 in ElmasriTypes of attributesSimple or composite attributesSimple (atomic) e.g. ageNotation: oval
Composite e.g. address = street + number + ZIP code + townNotation: Oval connected to several sub ovals.5Types of attributes IISingle valued or multi-valuedSingle valued e.g. CPRMulti-valued e.g. phone numberOne person may have several phonesNotation: Double ovalAn attribute may be composite and multi-valued!6
Figure 3.7 from chapt. 3 in ElmasriExercise in attributesTake a look at figure 3.7 from slide 6Start by yourself identifying the following terms in the diagram (5-10 min.):Simple (atomic)Composite Multi-valued
Continue discussing your solution with the three other students at your table - use RoundRobin (Danish: Ordet Rundt), where you try to agree on a mutual solution (10-15 min.)
Finally the solution should be presented/discussed in class7Types of attributes IIIDerived: Calculated from other attributes e.g. sum or averageNotation: Oval with a dashed border
An attribute with no value has value NULLValues does not existValue unknown8
Figure 3.15 from chapt. 3 in Elmasri, partlyRelationshipsRelationships between entities
Notation: rhomb (diamond)
Similar to association in OOA
Relationships may have attributesNotation: Oval9Relationships IIBinary relationshipRelationship between 2 entities (normal)
Relationships, higher degreeRelationship between more entities (rare)
Recursive relationshipsRelationship of 2 entities belonging to the same entity type e.g. an employee with a relation to a boss (another employee)10
Cardinality1-1very rare1 entity of type A has a relation to at most 1 entity of type B and vice versa1 husband ~ 1 wife
1-many, 1-Nvery common1 entity of type A may have relation to many entities of type B, not vice versa.1 department ~ many employees11Cardinality IIMany - many, N-Mcommon1 relation of type A may have relations to many entities of type B and vice versa.1 employee ~ many projects1 project ~ many employees
12Cardinality notationStep into the entity type and look at the other entity through the relation.How many entities of the other type do you see?Write the number on far end of the relation.13Exercise in relationships & cardinalityTake a look at figure 3.27 page 97 in the slides from Elmasri (physical page 43) approx. 30 minutesStart by pairing up with the student next to you and suggest the cardinality for each of the 10 casesAlso make a quick sketch for each case, so you know where to put the cardinalities
Share and discuss your solution with the other pair of students at your table
Finally the solution should be presented/discussed in class14(min, max) cardinalityOften youre only concerned with max. cardinalities
Sometimes you want both (min, max) cardinality.Note: Cardinalities placed in the other end of the relation!!!15NB!!!
History things evolveHistory: More generations of relationsCardinality goes up1 man ~ many wives [not simultaneously]
Put a timestamp / period on the relation (attribute on the relation)Relation marriage: start_date, end_dateend_date may be NULL :-)16Total participationOrdinary relationAn entity may be related to another entity
Total participationEn entity must be related to another entity.Min. cardinality 1 (not 0)Notation: Double line on the relation17
Weak entitiesAn entity that is dependent on some other entityIf the strong entity is deleted so is the weak entity
Notation:Weak entity: Rectangle with double bordersIdentifying relationship: Rhomb with double borders (shows the strong entity)18Weak entities IIA weak entity has a partial keyNot unique
Unique in combination with the key from the strong entity
Notation: Dashed line under the partial key19
Best practiceProcedure (best practice)find entities and [easy] attributesrelationshipscardinalitieskeysweak entities (if any)total participation (if any)20Assignment: Make E/R diagram for Amazon (see also week plan)Make an E/R diagram of the data behind Amazon http://www.amazon.co.uk
Focus on books only
Use a tool such as Dia (http://dia-installer.de/ ), Visio or a similar
Start today and continue at home, so you can present a solution next time in class upload your diagram in jpg format to the folder called ER solutions for Amazon in studie.rhs.dk21