Upload
ryanbalkaran
View
231
Download
0
Embed Size (px)
Citation preview
8/10/2019 Chapt 2 Entity Relationship Modeling
1/33
Lecture Notes on Database Chapter Two
ENTITY RELATIONSHIP MODELING
Overview
Introduction
Entity & Entity Cl!!
Attri"ute!
#ni$ue Identi%ier
Reltion!i'!
E()'le * Cri""en Air Trvel
E()'le * Credit Crd
N)in+ Reltion!i'
Introduction
The Systems Analyst uses education, experience, his own judgement and proven
methodologies to make sense of and to model organization behavior. e may then go onto represent such behavior!activity!event!structure in data. e may use "#"s to create a
model of the activities $processes% taking place in an organization. This includes
identifying the information that flows in the organization, where it flows to and from, andwhere it is stored. "espite the nomenclature, the "#" does not focus on the details of
data, so these &data stores' are not well defined in the "#". To create models which
would provide a picture of data stores we have to turn to (ntity )elationship *odeling.
Terrence +runton -
8/10/2019 Chapt 2 Entity Relationship Modeling
2/33
Lecture Notes on Database Chapter Two
n the /01-s there were several competing data modeling tools2 the file system model, thehierarchical model $+*'S *S database system%, and the 3etwork model $45"AS67,
oneywell's "S database system% developed by 4harles +achman. n /01-, the
relational model was introduced by (.#. 4odd. n /018, 9eter 4hen introduced (ntity:)elationship *odeling, which was a unifying methodology for file and database design
$A4* Transactions on "atabase Systems, *arch, /018%.
(ntity:)elationship *odeling allows us to define the re;uirements for data storage. t
involves identifying the significant things or (3TT(S in an organization, the relevant
properties or ATT)+ones, *ary Smith?s payment, etc.
Attri"ute
A data attribute is a characteristic common to all or most instances of a particularentity. Synonyms include property, data element, field. (.g. 3ame, address,
(mployee 3umber, pay rate are all attributes of the entity employee. An attributeor combination of attributes that uni;uely identifies one and only one instance of
an entity is called an identi%ier. (.g. (mployee 3umber is a primary key for
(mployee.
Reltion!i'
A data relationship is a natural association that exists between one or more
entities. (.g. (mployees process payments. Crdinlitydefines the number of
occurrences of one entity for a single occurrence of the related entity. (.g. anemployee may process many payments but might not process any payments
depending on the nature of her job.
Terrence +runton /
8/10/2019 Chapt 2 Entity Relationship Modeling
3/33
Lecture Notes on Database Chapter Two
Entity & Entity Cl!!
An (3TT6 is an object or event that the analyst wants to document. )emember thatthis object or event is being and happening in and!or out of the organization. The analyst
has to discover and represent these things, first, diagrammatically in an ()", and then indata. The entity is represented diagrammatically by a &box'with a name. Thename is in
all capitals and is singular.
The &box' may be of any size or shape. The analyst $you% gets to choose the size and
shape. +y stretching or shrinking the box, you find an appropriate size, large enough tohold any text you wish to enclose, and small enough to fit enough boxes on one page to
represent the system you wish to depict. 6ou must also allow enough size to connect
relationship lines to the box.
The analyst, through a study of the organization, discovers and identifies the things which
populate the organization space. These things are then classified by putting them inboxes and giving the boxes names. So that the entity name $the name in the box%, is the
name for a class of thing, not a single occurrence of the thing. So that the entity
A)95)T, represents a class of thing we call &airport', and consists of one or more thingssuch as 9iarco, @igie, and @ere +ird, each of which is an occurrence of the entity
A)95)T.
Attri"ute!
6ou would have considered attributes earlier when searching for entities. Thecharacteristics of entities, the things that draw them to your attention, are their attributes.
#or instance if we are talking about air travel, the first thing that you will probably notice
on the ticket is the name of the passenger, then the destination, the date and the flight
Terrence +runton
3A*(
A)95)T
e.g. 9iarco @igie
@ere +ird
8/10/2019 Chapt 2 Entity Relationship Modeling
4/33
Lecture Notes on Database Chapter Two
information. These are the attributes of ticket, or more specifically, as we shall soon see
in the example, coupon. #ormally stated, an attribute is any detail that serves to ;ualify,
identify, classify, ;uantify or express the state of an entity, or provide a description of athing of significance.
An attribute could be text, or numbers. t may also be a picture, as provided for in*icrosoft Access database management software. 7ess obviously, it may be a feel, a
smell, or some other intangible. #or data processing purposes, we tend to concentrate on
text and numbers, but other attribute types could be represented, particularly in theemerging area of multimedia.
An ellipse is used in the ()" to represent attributes. The ellipse is connected to the
entity using a line. The attribute's name, a noun, is written within the ellipse. $n *Sord, the ellipse shape with a text box inside%. This style of notation is used here since it
is the simplest type that most clearly identifies the attributes. 7ater we will discard this
style in favour of a more compact style.
hile it is not essential to show attributes on an entity relationship diagram, it is helpful
to clarify the nature of the entity and identify attributes early, for later use when definingdatabase tables.
An attribute describes only one entity, and it must describe only the entity against whichit is shown. This may seem obvious at first glance, but we may find in a real organization
that different entities may have attributes that appear to be similar. #or example, both the
entity student and the entity lecturer may have an attribute that may be called address.
As a rule of thumb, do not use more than seven attributes to describe an entity.
Sometimes relationships may be disguised as attributes, or attributes of one entity may be
mas;uerading as attributes of another. #or example, consider the case of employees andtheir departments in an organization. The entity (*9756(( may be shown as having
an attribute &department number', this is wrong. &"epartment number' is really an
attribute of the entity "(9A)T*(3T.
Terrence +runton B
date issued
time issued+5A)"3C 9ASS
8/10/2019 Chapt 2 Entity Relationship Modeling
5/33
Lecture Notes on Database Chapter Two
A 4omposite Attribute consists of other attributes and connects to its constituents using a
solid line=
A *ulti:@alued Attribute is one that may have multiple values. t connects to the entity
using a double line=
35T(= After 3ormalization, an entity may have only one value for an attribute at anytime. )epeated attributes must be removed from the entity. This is the first rule of
normalization, the removal of repeating attributes. e will look at 3ormalization more
closely later on.
A "erived Attribute is one whose value may be calculated $derived% from other attributes.
Since it can be derived, there is no need to store it. t connects to the entity using adashed line.
Terrence +runton D
address
street
city
statephoneE
ST
8/10/2019 Chapt 2 Entity Relationship Modeling
6/33
Lecture Notes on Database Chapter Two
An attribute name must be in the singular. f, when naming, it appears that the attribute
should be plural, this is an indication that missing entities with their own attributes may
be hiding here. An attribute can become an entity when it is a thing of significance,which has its own attributes and relationships.
#ni$ue Identi%ier
(ach uni;ue instance of an entity must be uni;uely identifiable by a combination ofattribute$s% and!or relationships $key%. 6ou must seek out candidate attributes that may
uni;uely identify an entity. Student ", invoice number, etc. are good candidate
attributes that would uni;uely identify the entities ST
8/10/2019 Chapt 2 Entity Relationship Modeling
7/33
Lecture Notes on Database Chapter Two
Layout Rules These are designed to make the diagrams easy to read and to
maximize the ;uality and accuracy.
H Arrange your diagram so the entity boxes line up and relationship lines are
mainly straight and horizontal or vertical. *inimize crossing lines. hen relationship
lines must cross, try to reduce clutter and use diagonal lines. Avoid using many closelyparallel lines. These are often difficult to follow.
8/10/2019 Chapt 2 Entity Relationship Modeling
8/33
8/10/2019 Chapt 2 Entity Relationship Modeling
9/33
Lecture Notes on Database Chapter Two
.-N /One0to0Mny1
N-. /Mny0to0One1
N-M /Mny0to0Mny1
E()'le o% .-.-
A 9rofessor teaches *A36 4lasses.
A 4lass is taught by 53( and only one 9rofessor.
E()'le o% M-N-
A Student enrolls in *A36 classes.
A 4lass contains *A36 Students.
Terrence +runton I
. Mteaches9)5#(SS5) 47ASS
enrolls
Crade
MN
7ast 3ame
Student "
ST
8/10/2019 Chapt 2 Entity Relationship Modeling
10/33
Lecture Notes on Database Chapter Two
*any to *any $3=*% )elationships must be transformed into two separate 5ne to *any
$/=3% )elationships. To do this a 4omposite (ntity is created. t is represented by a new
entity &box'.
Terrence +runton 0
Crade
4lass )oom EStudent "
N.
N. (3)577*(3T
7ast 3ame
Student "
ST
8/10/2019 Chapt 2 Entity Relationship Modeling
11/33
8/10/2019 Chapt 2 Entity Relationship Modeling
12/33
Lecture Notes on Database Chapter Two
Entity Relationship Model of the ticket:
Figure 2.2 %R/ o! the ticket
The nucleus of this simple system is the coupon. t is significant as the lowest commondenominator and has vital information such as its class and status. t can only exist
within the context of a ticket, from which it inherits the date of issue and fare.
(ach of the boxes in the ()" in #igure . above is an entity and the line between is a
relationship. The line has a forked $many% ending on the left and a single $one% ending on
the right, indicating that there can be many coupons on one ticket= a many to onerelationship. The line is solid to show that the relationship is mandatory. The
relationship can be read from the left to right to tell us that=
(ach 45
8/10/2019 Chapt 2 Entity Relationship Modeling
13/33
Lecture Notes on Database Chapter Two
7et us look at the ()" of the relationship between the T4M(T and the #7CT.
Figure 2.0 %R/ o! TIC%T to FLI3T Relationship
This shows that a coupon is in some way related to a flight. The diagram now reads from
left to right=
(ach 45
8/10/2019 Chapt 2 Entity Relationship Modeling
14/33
Lecture Notes on Database Chapter Two
(ach T4M(T must be made up of one or more 45
8/10/2019 Chapt 2 Entity Relationship Modeling
15/33
Lecture Notes on Database Chapter Two
N)in+ Reltion!i'
Terrence +runton BD
45*9A36
A445
8/10/2019 Chapt 2 Entity Relationship Modeling
16/33
Lecture Notes on Database Chapter Two
The name for each end of the relationship is placed near the appropriate end in lower case
as shown above.
To read any relationship simply but definitively, the following syntax is used=
must be(ach $and every% (3TT6 F A end:name:/
may be
53( A3" 5376 53( (3TT6 F + $ever%
&is that true5)53( 5) *5)( (3TT6 F + plural
And conversely=
must be
(ach $and every% (3TT6 F + end:name:/
may be
53( A3" 5376 53( (3TT6 F A $ever%
&is that true5)
53( 5) *5)( (3TT6 F A plural
Entity Reltion!i' Di+r)!
Terrence +runton BG
end0n)e0.
end0n)e03
(3TT6 A (3TT6 +
8/10/2019 Chapt 2 Entity Relationship Modeling
17/33
Lecture Notes on Database Chapter Two
Overview
This section discusses the following topics with respect to (ntity )elationship "iagrams$()"s%=
De%inition nd #!e AnEntity Relationship Dia%ra! &ERD' is a graphical representation of the
relationships among tables in a database
This representation can also be referred to as the ?data model,? ?database schema,?
or ?database diagram? among other names
An ()" represents the lo%ical relationshipsbetween tables2 it has nothing to do
with the way the data isphysicallystored in the database
There is no standard way to represent an ()", however some common
conventions discussed below
SP7 Server 1.-, includes a database diagramming tool that can easily create
()"s
9rior to version 1.-, SP7 Server did not have this capability so ()"s were
typically created in *icrosoft Access or with a third:party product like @isio
3ote that unlike Access, the SP7 Server 1.- diagram tool does not draw
relationships lines directly connecting to keys $i.e., the columns used to establish the
relationship%2 however, you can manipulate their position on the screen to point to theappropriate location
There is no standard way to draw an ()"2 several different conventions are used
T"le! Tables$a.k.a. entities or relations% are drawn as boxes
Colu!ns$ a.k.a. fields or attributes% are listed as rows by name inside the table
box #eysare usually annotated as 9M : primary key2 #M : foreign key2 and AM :
alternative key $an AM is a column that meets the re;uirements of a 9M but is not
designated as such2 it is a good candidate for sorts and indexes%
Terrence +runton B8
"efinition and
8/10/2019 Chapt 2 Entity Relationship Modeling
18/33
Lecture Notes on Database Chapter Two
The SP7 Server diagram tool does not follow this convention2 instead, the
primary key column$s% is designated with a ?key? icon to the left as shown below=
ithin the SP7 Server diagram tool, you can right:click on the table name bar
and choose ?4olumn 9roperties? to display detail for each column $data type,
nullability, etc.%2 there are also other display options available
Reltion!i'! Relationshipare represented by lines between the table boxes
A one(to(one relationshipmay be represented by a line without an endpoint2
sometimes it will be annotated with a ?/? or, in SP7 Server, with a ?key? icon on eitherend
A one(to(!any relationshipmay be represented by a line with a dot on the ?many?
end2 sometimes the line will be annotated with an ?3? or, in SP7 Server, with an
infinity symbol on the ?many? end
As discussed in )elationships, a !any(to(!any relationshipis simply two one:
to:many relationships as show below=
Terrence +runton B1
http://www.frick-cpa.com/ss7/Theory_Relationships.asp#NNhttp://www.frick-cpa.com/ss7/Theory_Relationships.asp#NN8/10/2019 Chapt 2 Entity Relationship Modeling
19/33
Lecture Notes on Database Chapter Two
Sometimes the ()" graphically distinguishes between dependent and
independent relationships
A dependent relationshipis one where the 9M of a dependent table is also a #M2
typically the dependent table box is drawn with rounded corners "ndependent tablesare drawn with s;uare corners
The SP7 Server diagram tool does not distinguish between independent and
dependent relationships
5ther designations sometimes used include=
o ): means ?one to zero or one? relationship
o :means ?one to one or more? relationship
o n: means ?one to exactly n? relationship
ERD %or te 4Pu"!4 Dt"!e
Terrence +runton BI
8/10/2019 Chapt 2 Entity Relationship Modeling
20/33
Lecture Notes on Database Chapter Two
ERD %or te 4Nortwind4 Dt"!e
Terrence +runton B0
8/10/2019 Chapt 2 Entity Relationship Modeling
21/33
Lecture Notes on Database Chapter Two
Reltion!i'!
Terrence +runton D-
8/10/2019 Chapt 2 Entity Relationship Modeling
22/33
Lecture Notes on Database Chapter Two
Overview
This section discusses the following topics with respect to relationships=
5!ic Crcteri!tic! o% Reltion!i'! n a relational database all data is organized into tables often referred to as
entities or relations. An advantage of the relational database model is its ability to establish
associations or ?relationships? between the tables.
A relationshipis a logical linking between two entities $tables% that describe how
they are associated with each other.
)elationships are used to enforce data integrity and facilitate joins to provide
access to multiple tables at the same time.
5ther database models $e.g., hierarchical or network% use explicit pointers to
associate pieces of data.
)elationships are represented by common data values stored in two tables.
(xample= a relationship is established between the customer and orders tables by
placing a customer " column in both tables2 each ?order? can then be ?related? to aparticular customer by the value in this common column.
The common columns that relate two tables are called &keys' $primary or foreign
key%.
n some cases a key can consist of one or more column in which case it is referred
to as a co!posite key$
A pri!ary key $9M% is a column $s% that uni;uely identifies each row in the
primary or ?parent? table.
The 9M not only ensures there are no duplicate rows but it also provides a
mechanism that allows you to reference all of the attributes $columns% of a specificrow simply by referring to one numeric value.
(xample= 6ou can reference any information about a particular customer simplyby referring to that customer?s ".
The 9M should be a small numeric key so that it is easy to sort, store and search.
A forei%n key $#M% in related or ?child? table inherits the primary key of the
?parent? or primary table.
Thus, a 9M:#M combination establishes a relationship between the parent and
child tables.
Terrence +runton D/
+asic 4haracteristics
mplementing )elationships in a "atabase
5ne:to:*any )elationships
5ne:to:5ne )elationships
)ecursive )elationships
8/10/2019 Chapt 2 Entity Relationship Modeling
23/33
Lecture Notes on Database Chapter Two
The cardinalityof a relationship defines how many instances of each entity relate
to each other.
There are three primary types of cardinality= one:to:one2 one:to:many2 and many:
to:many.
A recursi*e or refle+i*e relationshipis a relationship within a single table2 i.e.,
the same table acts as both the child and parent. The relationships among tables $entities% are shown graphically in an (ntity
)elationship "iagram $()"%.
I)'le)entin+ Reltion!i'! hen designing a database, an entity$table% is anything that contributes to the
business operation and can be described in terms of accessible data.
n other words, if you were describing the activity being modeled by the database,
the entities would typically be the nouns in your description. Relationships between entities &tables' are lo%ical, not physical$i.e., they don't
exist as separate objects in a database%.
)elationships are defined as a logical link between the primary key $9M% of the
parent table with the foreign key $#M% of the child table.
hen a relationship is created, the parent table contributes its primary key to the
child table where it is referred to as a foreign key.
n other words, the relationship is created by storin% the *alue of the # for the
parent in the -# colu!n of the child$
The general SP7 syntax for adding a primary key to a table is=
CONSTRAINT constraint6naePRIMARY 6EY$colun6nae% The general SP7 syntax for adding a foreign key to a table is=
CONSTRAINTconstraintQname 7OREIGN 6EY$columnQname%
RE7ERENCESparentQtableQname $columnQnameQinQparentQtable%
3ote that the #M must references a column in another table.
A #M can only reference a column that has either a 9)*A)6 M(6 constraint or
a
8/10/2019 Chapt 2 Entity Relationship Modeling
24/33
Lecture Notes on Database Chapter Two
The classic example of a one:to:many relationship is that of ?customers? and
?orders2? each customer $parent% can have many orders, but each order $child% can be
related to only one customer.
To implement this relationship, a ?customer "? column is added to the ?orders?
table $#M% and referenced to ?customer "? column in the ?customers? table $9M%.
Mny0to0Mny /N0N1 n a many:to:many relationship, !any instances of one entity are associated
with !any instances of another entity$
The classic example of a many:to:many relationship is that of ?orders? and ?parts?.
(ach order can consist of many parts andeach part can be used in many orders.
This type of relationship cannot be established directly.
A third table, called a /unction tableor associatin% table, is used to establish the
relationship.
A junction table typically has a composite 9M that consists of two or more
columns that also serve as #Ms.
n effect you have two one:to:many relationships linked via the junction table that
together produce a single many:to:many relationship.
n the classic ?5rder (ntry? database example, the junction table is referred to as
the ?order detail? table2 it implements the many:to:many relationship between ?orders?and ?parts?.
The ?order detail? table contains an ?orderQ "? column that functions as a #M and
relates it to the ?orders? table2 the result is a one:to:many relationship between ?orders?
and ?order details?.
The ?order detail? table also contains a ?partQ "? column that functions as a #M
and relates it to the ?parts? table2 the result is a one:to:many relationship between
?parts? and ?order details?.
Terrence +runton DB
8/10/2019 Chapt 2 Entity Relationship Modeling
25/33
Lecture Notes on Database Chapter Two
ithin the ?order detail? table, the ?orderQ "? and the ?partQ "? together are
defined as a co!posite pri!ary key$
Taken all together, the two one:to:many relationships $orders:RorderQdetail and
parts:RorderQ detail% constitute a many:to:many relationship between ?orders? and
?parts?.
One0to0One /.0.1 n a one:to:one relationship, one instance of one entity is associated with a
sin%le instance of another entity.
This type of relationship is not very common.
n order to evaluate the need for a one:to:one relationship, ask yourself why you
can?t just use one large table.
+y implementing a one:to:one relationship you are in effect vertically partitioninga table $splitting it into two pieces%.
There are typically two reasons for vertically partitioning a table by implementing
a one:to:one relationship= /% security and % performance.
(xample= 6ou split the employee table into two pieces so that salary and other
sensitive information can be stored in separate table $security%.
(xample= Some columns in a large table are not accessed fre;uently or contain
large data types so they are moved to a separate table $performance%.
n the illustration above, the ?publishers? table is split into two pieces2 one to hold
the smaller, more commonly accessed fields and another to hold the less fre;uently
re;uested data fields that include large data types $the ?logo? field is an image datatype and the ?prQinfo? field is a text data type%.
Recur!ive Reltion!i' A recursi*erelationship refers to a relationship established within a table.
n other words, a table is ?related? to itself.
)ecursive relationships are usually established in situations where it is useful to
perform a self:join.
The classic example of a self(/oin is the ?employee:manager? report. n this
situation, the ?employees? table contains name, " and ?reports to? columns. The
?reports to? column contains the " $not the name% of the employee?s manager. n order
Terrence +runton DD
8/10/2019 Chapt 2 Entity Relationship Modeling
26/33
Lecture Notes on Database Chapter Two
to prepare a report that lists employees and their managers by their naes, a self:join
is re;uired..
n this situation, the ?reports to? column is typically made a #M that references the
9M ?employee "? field.
(stablishing this internal relationship allows referential integrity to be enforced
$e.g., you cannot insert a manager " into the ?reports to? column that does not exist
in the employee " column%.
A recursive relationship is sometimes referred to as a refle+i*e relationship$
The above was adapted from a website by "avid ). #rick 4o., 49A $http=!!www.frick:
cpa.com%
E8AMPLE T9O
TOYOTA TRINIDAD AND TO5AGO LIMITED
5AC6GRO#ND
Toyota Trinidad and Tobago 7imited $TTT7% business type is classified as an automotivedealership. TTT7. specializes in providing sales and services of their vehicles that are of
high ;uality, safe, reliable and durable. Thus, they offer a range of vehicles to meet theneeds of their customers, from the adventurous to the business type.
To support its sales and services, TTT7 puts its customers at the center of everything itdoes by delivering custom made vehicles to the buyer's specifications and providing
;uality service in the timeliest manner. ence, the company has developed a vast
Terrence +runton DG
8/10/2019 Chapt 2 Entity Relationship Modeling
27/33
Lecture Notes on Database Chapter Two
database on its customers that includes their preferences for styling, model types, colours,
prices and other features.
The building compound is partitioned into a reception area, sales area $which includes a
showroom%, a service bay $including a garage%, warehousing facilities, offices and ample
parking for its customers.
Toyota's computers and peripherals are connected through a local area network. This
network enables the departments and the people within those departments to shareinformation and resources. The primary purpose for maintaining and operating the
network is to share identical data that is always available to, and modifiable by, different
people simultaneously.
n dealing with the service aspect of TTT7, the database structure will support the heavy
flow of transactions that take place on a daily basis. Although this project considers only
the service aspect of TTT7, the description of the business operations helps to establish
several processes namely, inventory, job orders, invoicing.
(ach transaction will generate a set of procedures supported by a database design moduleand within each module a set of entities will be defined. The remaining description of
operations will add the re;uired detail and will help define other processes, entities,
attributes, relationships, etc.
t is true that in order for any business to survive and thrive, its business objectives must
be synchronized with its business type. ith this in mind, the business objectives must
be defined precisely and in detail. Since the business objectives are so closely tied to thebusiness type, they help audit the initial database components. #or example, while the
business objectives are likely to add attributes and entities to the database design, they
should not yield database components that are in conflict with those re;uired by thebusiness type.
Co)'ny O":ective!
/. To maintain and manage sustainable sales growth
This objective re;uires designing Toyota's operations to foster customer loyalty
and to attract new customers by=
a. *aintaining an inventory of products that meet customer needs.
b. *aintaining and improving order response time.
c. "elivering ordered products ;uickly and efficiently.d. *aintaining customer contact through follow:up actions.
e. *aintaining price competitiveness through operational cost control.
. To maximize net sales returns by maintaining and improving cost controls through=
a. (fficient data access and data:to:information transformation to improveinventory management
Terrence +runton D8
8/10/2019 Chapt 2 Entity Relationship Modeling
28/33
Lecture Notes on Database Chapter Two
b. The customer order process.
c. The vendor order process.
d. The shipping process.e. The back:order process.
f. The product return process.
5u!ine!! Rule! & ERD!
Te ;o" Order Module
A customer is someone who has purchased a Toyota vehicle in the past.
/. 4ustomers of Toyota own cars. This business rule establishes two entities,
45+Q5)"(). This establishes a /=* relationship
between service advisor and job order as a service advisor can generate more than onejob order.
D. hen a customer brings in a car for servicing, the car is entered on a job order. Arelationship is created between 4A) and >5+Q5)"(). 5nly one car can be enteredon one job order but over time, one car can generate many job orders.
Te ;o" Order Module ERD
Terrence +runton D1
enters
owns4A)45+ 5)"()
8/10/2019 Chapt 2 Entity Relationship Modeling
29/33
Lecture Notes on Database Chapter Two
Te Invoicin+ Module
The invoicing module will be based on the following business rules.
/. An invoice is generated only when a customer makes a purchase. This business rule
establishes that 4
8/10/2019 Chapt 2 Entity Relationship Modeling
30/33
Lecture Notes on Database Chapter Two
Te Invoicin+ Module ERD
Te Servicin+ Module
/. There are different types of employees. This establishes the entity of(*9756((QT69(. (ach employee is of one employee type. This establishes a /=/
relationship between (*9756(( and (*9756((QT69(.
. The employee of type garage foreman accepts the vehicle and the job order from theservice advisor. This business rule establishes three entities, 4A), >5+ 5)"() and
(*9756((. There is a mandatory relationship between job order and car and an
optional relationship between >5+ 5)"() and (*9756((, in that vehicle ismandatory to >5+ 5)"() and >5+ 5)"() is optional to (*9756((. There is
only one vehicle per job order. There is a /=* relationship between >5+ 5)"() and
(*9756(( as an employee could have performed many service jobs on onevehicle.
B. The garage foreman analyses the job order information and assigns the job or job
segments to the appropriate technical team. This establishes the entity of T(A*, and
Terrence +runton D0
is returned to
has
>5+ S((TS()@4(A"@S5)
(*9756((
contains
is written in9A)T 3@54( 73(
generates
writes
4
8/10/2019 Chapt 2 Entity Relationship Modeling
31/33
Lecture Notes on Database Chapter Two
establishes that T(A* is mandatory to >5+ 5)"(). Also, this establishes a
relationship between T(A* and (*9756(( such that the T(A* is made up of as
many as five (*9756((S and each (*9756(( belongs to only one T(A*.There is a /=* relationship between T(A* and >5+Q5)"() as one T(A* can
work on more than one >5+Q5)"().
D. 9arts re;uired for the service job are sourced from Toyota's on:site warehouse. These
parts are used in the car. This rule shows the relationship between 9A)TS and 4A)
and establishes that more than one part can be used on a car.
G. 9A)TS are assigned to the job they are to be used for. This establishes a relationship
between 9A)TS and >5+Q5)"(), since 9A)TS used on the car will be placed on
the >5+Q5)"().
8. Specialized tools used in a job must be signed for by the technician using the
e;uipment. This creates the entity T557S, and established that >5+Q5)"() is
mandatory to T557S as such tool used must be tied to a service job performed. Thereis a /=* relationship between >5+Q5)"() and T557S as one >5+Q5)"() may
re;uire more than one T557.
Te Servicin+ Module ERD
Terrence +runton G-
is
assignedto
receives >5+ 5)"()
used on
workson
9A)T 4A)
uses
make up
is of(*9756(( (*9756((T69(
T557
T(A*
8/10/2019 Chapt 2 Entity Relationship Modeling
32/33
Lecture Notes on Database Chapter Two
Reltionl Sce)
Terrence +runton G/
nvoice
nvoice "4ustomer "
7icense 9latenvoice "ate
(mployee "
>ob 5rder "
(mployee
(mployee "Title
#irst 3ame7ast 3ame
AddressTown+irthdate)ecruitment "ate
Termination "ate9hone 3umber
*obile 3umber(mployee Type "
Team
Team "(mployee /(mployee (mployee B
(mployee D(mployee G
(mployee Type
(mployee Type "(mployee Type
"escription
9art
9art "9art "escription9art 4ost9art 9rice
9art Puantity9art *in. Puantity
nvoice 7ine
nvoice 7ine "7ine 3umber
9art "ob
arranty )epairnspection
)epeat )epair5ther*aintenance 7evel
8/10/2019 Chapt 2 Entity Relationship Modeling
33/33
Lecture Notes on Database Chapter Two