• Nem Talált Eredményt

– Avoid use of reserved words – Add a few attributes, if possible – Give the entity a unique name Entities

N/A
N/A
Protected

Academic year: 2022

Ossza meg "– Avoid use of reserved words – Add a few attributes, if possible – Give the entity a unique name Entities"

Copied!
27
0
0

Teljes szövegt

(1)

Entities

– Give the entity a unique name – Create a formal description of

the entity

– Add a few attributes, if possible – Be aware of homonyms

– Check entity names and descriptions regularly – Avoid use of reserved words

– Remove relationship name from entity name

(2)

HOTEL GUEST

guest of

host of

ACCOMMODATION PERSON

guest of

host of

Relationship Name in Entity Name

The second model is more general in its naming. It allows the addition of a second relationship between the same entities.

(3)

An Attribute...

– Always answers “of what?”

– Is the property of entity , not of relationship – Must be single valued

– Has format, for example:

• Character string

• Number

• Date

• Picture

• Sound

– Is an elementary piece of data

(4)

EM Entities and Attributes

user address password person name country birth date occupation message text

attachment file

folder inbox outbox

wastebasket Nouns

USER Address Password PERSON Name COUNTRY Birth Date Occupation MESSAGE Text

ATTACHMENT File

FOLDER Inbox Outbox

Wastebasket

Entities/Attributes/

Instances

USER - Address - Password PERSON

- Name - Birth Date - Occupation COUNTRY - Name MESSAGE

- Text

ATTACHMENT - Filename FOLDER

- Name

Entities with their Attributes

(5)

Attribute and Entity

• Attributes in one model can be entities in another.

GARMENT

CURRENCY PRICE NAME LANGUAGE

GARMENT Name Price

(6)

Redundancy

COMMODITY

* Name

* Price exclusive VAT

* Price inclusive VAT

* VAT %

Prevent using redundant attributes.

(7)

A Subtype ...

– Inherits all attributes of supertype – Inherits all relationships of supertype – Usually has its own attributes or

relationships or business functions – Is drawn within supertype

– Never exists alone

– May have subtypes of its own – Is also known as “Subentity”

(Address means mail address here.)

ADDRESS USER

LIST

(8)

Subtype: Rules

• Subtypes of the same entity must be:

– Exhaustive:

Every instance of a supertype is also instance of one of the subtypes.

• and

– Mutually exclusive:

Every instance of the supertype is of one and only one subtype.

A

NON B B

Name subtypes adequately:

C OTHER A

(9)

Relationship Names

MESSAGE sent by USER

sender of

reply of replied

to by

sent to

receiver of

(10)

Optionality

MESSAGE USER

written by

author of

reply of replied

to by

received by

receiver of

(11)

Optionality

Must every MESSAGE be received by a USER?

No: Yes:

Yes

Must every USER be receiver of a MESSAGE?

No

MESSAGE

receiver of received by USER

(12)

Degree

written by USER

author of

reply of replied

to by ATTACHMENT

with containing

<5

received by

receiver of MESSAGE

(13)

Degree

MESSAGE received by

receiver of

Can a MESSAGE be received by more than one

USER? Yes

Can a USER be the receiver of more than one MESSAGE ?

Yes

One: One or more:

USER

(14)

Nontransferability

(leads to nonupdatable foregin keys)

MESSAGE written by author USER of

reply of replied

to by FOLDER

filed in containing

received by

receiver of

(15)

1:1 Relationships Roles

PERSON

* Name

PATIENT

* Blood Type

EMPLOYEE

* Job acting as

role of acting as

role of

(16)

Redundant Relationships

PERSON TOWN

living in of COUNTRY

living in

located in

hometown of location

of

born in

of birth of

located in

location of

COUNTRY

PERSON TOWN

living in hometown

of

(17)

Relationships and Attributes

– An attribute can hide a relationship

– Relationship can be “downgraded” to attribute

ATTACHMENT

* Content

ATTACHMENT TYPE

* Name

with

of ATTACHMENT

* Type

* Content

(18)

Attribute Compared to Relationship

– Easy model – Fewer tables – No join

– Value control – List of values

– Other relationships

ATTACHMENT

* Type

* Content

ATTACHMENT

* Content

ATTACHMENT TYPE

* Name

with

of

(19)

EMPLOYEE JOB

* Id

BADGE

NATIONALITY ADDRESS NAME

SALARY GENDER

TEAM

Attribute or Entity

(20)

Attribute Compared to Relationship

– There is no such thing as a foreign key attribute (Folder name)

– Usually, the attribute name should not contain an entity name (Message Id)

MESSAGE

* Message Id

* Text

* Folder Name

FOLDER

* Name

placed in containing

(21)

PRODUCT CUSTOMER

* Id

* Name * Code

* Name bought by

buyer of

Attribute of Relationship ?

Quantity

Relationships cannot have attributes. We need a new Entity .

(22)

CUSTOMER

* Id

* Name PRODUCT

* Code

* Name

ORDER with

with

for of

New Entity ORDER

*Quantity Sold

Name Sanchez Lowitch Yomita CUSTOMERS

Id 1 2 3 4

PRODUCTS Code

1 2 3 4

Name Jeans Shirt Tie

ORDERS Ctr_id

1 1 2 3

Pdt_code 2 3 2

Quantity_sold 2 2 1

(23)

ORDER

* Id

* Date with

with

for of CUSTOMER

* Id

* Name PRODUCT

* Code

* Name

Multiple PRODUCTS for an ORDER

?

(24)

for for ORDER ITEM

with

with

of

with CUSTOMER

* Id

* Name PRODUCT

* Code

* Name

ORDER HEADER

* Id

* Date

Another New Entity: ORDER ITEM

*Quantity Sold

(25)

PERSON

CUSTOMER TYPE classified

as

classification of external

Resolving m:1 Relationship

internal

(26)

Resolving m:1 Relationship

PERSON CUSTOMER TYPE

internal external

in

CLASSIFICATION with

for with

(27)

Normalization Rules

Normal Form Rule Description

First Normal Form All attributes are single valued.

Second Normal Form (2NF) An attribute must be dependent upon entity’s entire unique identifier.

Third Normal Form (3NF) No non-UID attribute can be dependent on another non-UID attribute.

“A normalized entity-relationship data model automatically translates into a normalized relational database design”

“Third normal form is the generally accepted goal for a database design that eliminated redundancy”

Hivatkozások

KAPCSOLÓDÓ DOKUMENTUMOK

Suppose a Transylvanian said, &#34;If I am either a sane human or an insane vampire, then Count Dracula is still alive.. Could it be inferred whether Dracula

As for organization entities in Wikidata and COURAGE, we used 4 properties for matching: name, type, country, and GPS.. The statistics, which were calculated for 457

In Maramures there are also institutions which at a certain moment gathered significant collections: The Ethnographic and Folk Art Museum of Baia Mare, The Faculty

As is shown in Table 1, drafters of the Fundamental Law have put the country name “Hungary” into the position of the long form of state name or constitutional state name in 2011,

Although a few studies have analyzed some of the current associations, to date, no attempt has been made to investigate the possible links between different attachment patterns

The Rh(  5 -C 5 Me 5 ) complexes of the studied bidentate (N,N) donor containing ligands (dmen, tmeda, pin, phen) have a chlorido ligand as a leaving group in their

In conclusion, we have developed an alternative, simple and convenient synthetic route to the access of 2-chloroethoxy- arenes using palladium-catalyzed

For instance, let us examine the following citation from a paper on the composition of the 11 th –13 th -century given name stock of Hungary by Katalin Fehértói (1997: