hazırlayan modelling the data structure entity modelling & entity relationship diagrams...

41
Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Upload: hilary-dennis

Post on 05-Jan-2016

234 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Hazırlayan

MODELLING THE DATA STRUCTURE

Entity Modelling & Entity Relationship Diagrams

Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Page 2: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

(Structured System Analysis & Design Methodology - SSADM)

Data Flow Diagrams (DFD)• DFDs show the processes, or functions, involved in a system. • They don’t tell us much about the structure of the data.

SSADM

entity model (or Logical Data Model)

Page 3: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Entity Modelling

SSADM

• Entity Models

– Real data– How the data connected?

Page 4: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Entities

SSADM

• things we might want to keep information about– People like CUSTOMER– Objects like PRODUCT

Swillbuckets Club

• MEMBERS• RECIPES• EVENTS• ARTISTES• SUPPLIER• DRINK

Medical Centre

• PATIENT• DOCTOR• NURSE• APPOINTMENT• WORK DATA• PRESCRIPTION

Page 5: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Is it an «entitty»?

1. An entity must be important to the organization.

2. An entity must have at least one attribute

3. An entity must occur more than once

4. Each entity occurrence must be uniquely identifiable

SSADM

MEMBER Membership number

RECIPE Recipe number

Page 6: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Representation form for entitites

• rectangles with rounded corners in Entity Models

• The name of the entity is always singular!!• RECEIPT• DRINK• PATIENT

SSADM

Page 7: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

ATTRIBUTE

• 1980’lerin başında kullanılmaya başlanmıştır.• SSADM SSADM, genellikle devlet bilgisayar projeleri için bir gereklilik olarak belirtilen İngiltere'de yaygın olarak kullanılan bir bilgisayar uygulama geliştirme yöntemidir. Giderek Avrupa'da kamu sektörü tarafından kabul edilmiştir.• SSADM kamu malıdır ve İngiliz Standardı BS7738 ile belirtilir.

Attributes are bits of data associated with the entityEntity: MEMBERAttributes:

– Member Name – Membership Number– Member Address– Date of Birth– Type– Seconder– Renewal Date

Page 8: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

A full membership record

Page 9: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Keys

A key is a way of identifying something

My key: Zehra Kamışlı Öztürk (It’s how other people identify me)

SSADM

Brilliant ??

Zehra Öztürk (Yard.Doç.Dr. Anadolu Üniversitesi)Zehra Öztürk (X Bank)Zehra Öztürk (Dr. Y Hospital)

t.r. identity number

Page 10: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Keys

• Zehra KAMIŞLI ÖZTÜRK• Zehra ÖZTÜRK - ANADOLU ÜNİVERSİTESİ

??

Page 11: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Keys

• an entity is made up of a number of attributes. Toidentify that entity, we need a key.

• Unique … primary key

– it’s made up of just one attribute.

Page 12: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Relationships

• Entitites have relationships with other entities

SwillbucketsArtistes entertain Members

Members attend Events

Artistes perform at Events

Students attend Classes

Students have Tutors

Tutors give Classes

Page 13: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Relationships

• The entities are joined together by a verb which describes the relationship between them.

• In an entity model, related entities are joined by a line

Page 14: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Relation Types

• one-to-one (1:1)•

Page 15: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Relation Types

• one-to-many (1:M)

Page 16: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Relation Types

• many-to-many (M:N)

Page 17: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Relation Types

• one-to-many (1:M)

PATIENT DOCTOR

EVENT ARTISTE

Page 18: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

M:M

• Sadly, many-to-many relationships are not good for

databases. They cannot be implemented effectively.

• So many-to-many relationships have to be resolved.

Page 19: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

M:M

• many-to-many (M:M)

STUDENT COURSE

CUSTOME PRODUCT

Page 20: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Resolving many-to-many relationships

• we have to split many-to-many relationships into two one-to-many relationships.

• This requires us to find a link entity which is a single occurrence of the many-to-many relationship.

1. Find a link entity

Page 21: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

2 Consider the attributes• When we create a new link

entity in this way, we need to consider which attributes will make up the new entity.

• There will be one or two from the original two entities, but there may be some completely new ones.

Resolving many-to-many relationships

Page 22: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

2 Consider the attributes• When we create a new link

entity in this way, we need to consider which attributes will make up the new entity.

• There will be one or two from the original two entities, but there may be some completely new ones.

Resolving many-to-many relationships

Page 23: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

COURT DEFENDANT

Court no Defendant no

Court name Defendant name

Court address Defendant address

Postcode Postcode

Court type date of birth

Court clerk Current status

TRIALCourt no*DEfendant no*Trial noTrial dateJudgeChargeDefence lawyerProsecutor

Page 24: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Simple steps in entity modelling

1. List the possible entities.

2. Check that the entities listed are really entities.

3. Draw a basic entity model, with boxes around the entities.

4. Identify which entities are related. Draw a line between them.

5. Give the relationship a name in each direction.

Page 25: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Simple steps in entity modelling

6 Identify the relationship type.

(1:1, 1:M or M:N)

7 Resolve any one-to-one relationships.

8 Resolve any many-to-many relationships.

Add in link entities.

9 Add the attributes, including primary keys and foreign keys.

Page 26: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Resolution and Naming the relationships

Page 27: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Entity Modeling

• The systems analyst will need to communicate regularly with the user

• during this process in order to check that all necessary entities have been identified and that the relationships are accurate.

Page 28: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

CASE: Entity modelling at Swillbuckets

1. List the possible entities.

ARTISTE EVENT MEMEBER DISH

BREWERY DRINK RECIPE

SUPPLIER MEDIA

1. An entity must be important to the

organization.

2. An entity must have at least one attribute

3. An entity must occur more than once

4. Each entity occurrence must be uniquely

identifiable

ARTISTE

EVENT

MEMEBER

DISH

BREWERY

DRINK

RECIPE

SUPPLIER

MEDIA

Page 29: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

CASE: Entity modelling at Swillbuckets

3. Draw the basic entity model

there may be more entities to come when we show the user our entity

model.

Page 30: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

CASE: Entity modelling at Swillbuckets

4 Identify the relationships.

ARTISTEs attend EVENTs

MEMBERs attend EVENTs

EVENTs provide DISHes

DISHes require RECIPEs

SUPPLIERs supply DRINKs

MEDIA cover EVENTs

Page 31: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

CASE: Entity modelling at Swillbuckets

4 Identify the relationships.

Page 32: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

CASE: Entity modelling at Swillbuckets

5 Give the relationships a name, in each direction!!

Page 33: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

CASE: Entity modelling at Swillbuckets

6 Identify the type of relationship.

each EVENT will only ever offer one dish (in order to keep Freddo Smitho just the right side of sane) and each dish will be offered at many EVENTs.

each RECIPE could require many FOOD ORDERs and each FOOD ORDER could be required for many RECIPES.

Page 34: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

CASE: Entity modelling at Swillbuckets

7 Resolve any one-to-one relationships.

Page 35: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

CASE: Entity modelling at Swillbuckets

8 Resolve any many-to-many relationships.

find a link entity

Page 36: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

CASE: Entity modelling at Swillbuckets

8 Resolve any many-to-many relationships.

Page 37: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

CASE: Entity modelling at Swillbuckets

9 Add the attributes and keys.• Primary keys are underlined.• Attribute names have been condensed into one word with no spaces –

– spaces can cause problems in some systems. Capital letters are used to denote a new word in the name.

• An asterisk denotes a foreign key –– an attribute which acts as a link to another entity by appearing in both. It’s a primary

key in one entity but not in the other.

• Address attributes are shown as just one attribute, but in reality they are– usually made up of a number of attributes e.g. Street, Town, County, Postcode.

Page 38: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

CASE: Entity modelling at Swillbuckets

Page 39: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Physical data store/entity cross-reference

1 List all the data stores, by checking the current physical DFD

• M1 Membership shoebox• M2 Artiste shoebox• M3 Supplier shoebox• M4 Events folder• M5 Recipe book

Page 40: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Physical data store/entity cross-reference

2 Cross reference each data store with corresponding entities from the entity model.

A data store can have more than

one entity

Page 41: Hazırlayan MODELLING THE DATA STRUCTURE Entity Modelling & Entity Relationship Diagrams Yard.Doç.Dr. Zehra KAMIŞLI ÖZTÜRK

Physical data store/entity cross-reference

3 Check that each data store has at least one entity.4 Check that each entity is stored in a data store.

• We note that the entities EVENT TICKET and MEDIA do not have data stores. The fact that EVENT TICKET does not have a data store is expected.