450 likes | 581 Views
D111-Data Fundamentals. Week 3. Objectives. Identifying relevant entities Identifying the relationships Entity Matix.
E N D
D111-Data Fundamentals Week 3
Objectives • Identifying relevant entities • Identifying the relationships • Entity Matix
"As a salesman, I'm responsible for 10 clients . Each of my clients makes an appointment to come into the showroom to view the merchandise we have to offer for the current season. Part of my job is to answer any questions they have about our merchandise and make recommendations regarding the most popular items . Once they make a decision on the merchandise they'd like to purchase, I write up a sales order for the client. Then I give the sales order to my assistant, who promptly fills the order and sends it to the client."
The List • Salesman • Client • Appointment • Showroom • View • Merchandise • Season • Question • Recommendations • Item • Decision • Purchase • Sales Order • Assistant • Sends Order
Review the List • Decide what are entities as opposed to attributes • Rule of thumb: • An entity should contain more than one attribute to describe it (other than its ID) otherwise its probably an attribute. E.g. Season? • Identify entities that have a different name but are a similar thing and eliminate one e.g. (Merchandise and Item or Purchase and Sales Order or Salesman and ). • Decide and keep only what are the important entities (points of interest to the business). • Look for items in the list that may be derived from the other entities e.g. Recommendations (Are they based on the result of the number of previously sold items?) • While Salesman and Assistant are types of employees and share similar attributes we will leave them as separate entities for now, just to keep it simple.
Attribute • Definition - In general, an attribute is a property or characteristic of an entity: • Colour = an attribute of your Hair. • First name = an attribute of a Person • Sale Price = an attribute of a Sale Item
Review the List Salesman Client Appointment Showroom View Merchandise Season Question Recommendations Item Decision Purchase Sales Order Assistant Sends Order • Salesman • Client • Appointment • Item • Sales Order • Assistant
Remember that not all entities are directly related to each other
Start from the top entity on the left side and intersect it with the left most entity on the topYou must examine the relationship between each one from the left sides point of view (Salesman/Salesman)
You must examine the relationship between each one from the left sides point of view (Salesman/Client)
You must examine the relationship between each one from the left sides point of view (Salesman/Appointment)
Keep moving from the left side list: top to bottom – left to rightYou must examine the relationship between each one from the left sides point of view (Client/Salesman)
How do I determine the type relationship? • Ask the following question: • could a single record in (name of first entity) be associated with one or more records in (name of second entity)? • If the answer is yes, we need to determine how many AND the context of the relationship (In what way are they related?). Is it: • Ownership Oriented or • Action Oriented
Relationship Context Categories Two types of categories • Ownership-Oriented questions include words or phrases such as: • own, belongs to,has, partof, orcontain... • Action-Oriented questions include action verbs such as: • make, visit, teach, sell, attend...
Ownership-Oriented Context own, belong to,has, have, partof, contain ... • Examples : • Can a single Salesman own one or more Salesmen? • Can a single Salesman belong to one or more Salesmen? Make sure it makes sense: • Can a single Salesman contain one or more Salesmen? • Can a single Salesman be managed by one or more Salesmen?
Action-Oriented Context • make, visit, teach, sell, attend... • Examples : • Make sure it makes sense: • Can a single Salesman make one or more Salesmen? • Can a single Salesman sell one or more Salesmen? • What is the nature of the relationship according to the system required. For example: • Can a single Salesman visit one or more Salesmen? • Yes they can, but does it fit with the requirements? • Can a single Salesman manage one or more Salesmen?
What type of relationship is it? • One to One (1:1) • One to Many (1:N) • Many to Many (N:N)
Conceptual Stage • We are still at a CONCEPTUAL stage of the development process.
Given the two SALESMAN entities, ask the question: • Can a singlesalesman be managed by one or moresalesmen? • If a relationship exists, enter the relationship name and relationship type (either a 1:1, 1:N or N:N) in that intersecting cell.
A relationship between two entities must be read from both sides. • Can a singlesalesmanmanageone or more salesmen. • If yes, enter the relationship name and relationship type into the intersecting cell
Remember that the examples given are subjective. The exact number will depend on each individual business.
The Official Conceptual Relationship • Apply the appropriate formula to the two entries and identify the official relationship between the tables.
1:1 + 1:1 = 1:1 • A pair of tables bears a one-to-one relationship when: • a single record in the first entity can be related to only one record in the second entity, and.. • a single record in the second entity can be related to only one record in the first entity.
1:N + 1:1 = 1:N • A one-to-many relationship exists between a pair of entities when: • a single record in the first entity can be related to one or more records in the second entity, and.. • a single record in the second entity can be related to one record in the first entity.
1:N + 1:N = M:N • A pair of entities bears a many-to-many relationship when: • a single record in the first entity can be related to one or more records in the second entity and.. • a single record in the second entity can be related to one or more records in the first entity.
Applying the formula • For the example between SALESMAN and SALESMAN the formula is: 1:1 + 1:N = 1:N One to Many
Add to Conceptual ERD • Now enter the two entity/s into your ERD and apply the relationship. Notice the lack of exact numbers. manages SALESMAN managed by
You must examine the relationship between each one from the left sides point of view (Salesman/Client)
Given the SALESMAN and CLIENT entities, ask the question: • Can a singlesalesmanhaveone or moreclients? • If a relationship exists, enter the relationship name and relationship type (either a 1:1, 1:N or N:N) in that intersecting cell.
You must examine the relationship between each one from the left sides point of view (Salesman/Client)
A relationship between two entities must be read from both sides. • Can a singleclientbelong to one or more salesmen. • If yes, enter the relationship name and relationship type into the intersecting cell
Applying the formula • For the example between SALESMAN and CLEINT the formula is: 1:1 + 1:N = 1:N One to Many
Add to Conceptual ERD manages SALESMAN managed by has belongs to CLIENT
Exercise • Complete the rest of the Matrix. Look for direct relationships among the following: • SALESMAN /APPOINTMENT • APPOINTMENT/ SALESMAN • SALESMAN /ITEM • ITEM/ SALESMAN • SALESMAN /SALES_ORDER • SALES_ORDER/ SALESMAN • SALESMAN /ASSISTANT • ASSISTANT/SALESMAN • CLIENT/APPOINTMENT • APPOINTMENT/CLIENT • ...