Reaves.dev

v0.1.0

built using

Phoenix v1.7.12

Extended Entity Relationship Model

Stephen M. Reaves

::

2023-05-29

Notes about Lesson 3 of CS-6400

Summary

Entity Types and Entity Surrogates

Entity type names must be unique.

Entities are represented by rectangles.

Properties are represented by ovals.

GUserUser

Single Valued Properties

Single Valued Properties only have the property name in the oval.

Proptery values are:

GUserUserEmailEmailUser--EmailPasswordPasswordUser--Password

Identifying Properties

An underlined property type identifies the entity

GUserUserEmailEmailUser--EmailPasswordPasswordUser--Password

This is the primary key.

Every entity must be uniquely referenceable.

Composite Properties

The value of some properties may be composed of other properties.

GUserUserEmailEmailUser--EmailPasswordPasswordUser--PasswordNameNameUser--NameFirstNameFirstNameName--FirstNameLastNameLastNameName--LastName

Multi Valued Property Types

Modeled by double oval.

An entity can have multiple multi-valued properties.

For example, a user can have multiple interests.

GInterestInterestUserUserUser--Interest

Relationship Types

Represented by diamonds, cardinality is represented by numbers on the edges.

A partial function is a mapping between entities that may not include every instance of a given entity.

GmuMale UsercmCurrentMarriagemu--cm1fuFemale Usercm--fu1

Having N instead of a number means many

Mandatory relationships have a bold line and are called a total function.

GeEmployerjCurrentJobe--j1uUserj--uN

You can also have N-M relationship types.

GsSchoolaAttendeds--aNuUsera--uM

Relationships can be between more than two entities.

GetmEventTeamMemberuUseretm--uLtTeametm--tMeEventetm--eNpPositionetm--pemailEmailu--emailtnTeam Namet--tnenEvent Namee--en

Many ternary relationship types cannot be reduced to a conjunction of binary relationship types.

Imagine how the below is different from the above.

GutUserTeamtTeamut--tueUserEventeEventue--eteTeamEventte--tuUseru--utu--ueemailEmailu--emaile--teenEvent Namee--entnTeam Namet--tn

Entities can be identified by their relationships, or a combination of their relationshiops and their properties.

GpPosteduUserp--uemailEmailu--emailsStatuss--pdtDateAndTimes--dt

In the above, Status cannot:

DateAndTime and Email identify Status.

Status is therefore a weak entity type and DateAndTime would be a partial identifier.

Note, DateAndTime should be a regular oval with a dashed underline, but idk how to do that in graphviz.

Recursive relationship type

Recursive relationship types relate an entity back to itself.

GmManagesuAdminUserm->uSuperviseeu->mSupervisoremailEmailu->emailsdSinceDateu->sd

Supertypes and Subtypes

A subtype is-a supertype.

For instance, every male user is-a user.

The is-a relationship is modeled with circle and either a d if it is disjoint or a o if it allows for overlap.

Properties are inherited similar to OOP.

GuUserfFemaleddf->dmMalem->drRegularUseroor->oaAdminUsera->od->uo->uemailEmailemail->upPassowordp->ullLast Loginll->abdBirth Datebd->rccCurrent Citycc->r

Union Entity Types

Union entity types are composed of multiple different entities where an instance of the union has to be a instance of 1 and only 1 subset entity.

GuUsercjCurrentJobu->cjeEmployerempUe->empcCompanygGovt Agencycj->eemp->cemp->geinEINein->caidAgency Idaid->ganAgency Namean->aidmMunicipalitym->aid

Relationship Objectification

In order to turn a relationship into an entity, you split the relationship into two and add an entity between them.

So this:

GuUsersaSchoolsAttendedu->saNsSchoolsa->sMgpaGPAgpa->sa

Becomes this:

GuUsersa1u->sa11sSchoolsaSchools Attendedsa2sa->sa2Msa1->saNsa2->s1gpaGPAgpa->sa

What can EER do?

Classification is handled by entity types.

Generalization is handled by Super/Sub types.

Aggregation is not explicitly handled by EER.

Great for fixing and representing a perception of reality.

What about Queries?

Queries do not have a type in EER.

The closest thing is a list of properties.

This is why DBMS’s don’t rely on EER and instead use relational data models.

Relational Model

Data Structures

The only structure is relations.

Domain := a set of atomic values

Relation := a subset of the set of ordered n-tuples in a domain.

R<d1,d2,...,dn>diDi,i=1,...,n R \subset {<d_1, d_2, …, d_n> | d_i \in D_i, i=1, …, n}

Attribute := a unique name given to a domain in a relation helping us interpret domain values.

Tables

We illustrate relations by tables.

RegularUser:

Email varchar(50)BirthDate datetimeCurrentCity varchar(50)Hometown varchar(50)Salary integer
[email protected]1985-11-07SeattleAtlanta10,000

Order of attributes and tuples are idenpendent of relation

Constraints

If an attribute is a key of a table, it can’t be null or duplicated.

If an attribute references a key of another table, it must be a subset of the values of that key.