Академический Документы
Профессиональный Документы
Культура Документы
Tables
Remedios de Dios Bulos
friend1 EMPLOYEE 1..* 1..1 DEPARTMENT
0..* staff WorksFor
Friends
EID {PK} DNo {PK}
EName 0..1 1..1 DName
0..* ELastName
EFirstName manager DLocation
friend2 EMI 0..1
EAddress
ERD EStNo MANAGES {R}
Controls
EStName
Company ECity MgrStartDate
POSITION
Field Data Type Length Required Foreign Key
PNo{PK} char 10 Not null
PName char 50 Not null
Salary money
PROJECT
Field Data Type Length Required Foreign Key
PrNo{PK} char 10 Not null
PrName char 50 Not null
DNo char 10 Not null DEPARTMENT
MACHINE
Field Data Type Length Required Foreign Key
MNo{PK} char 10 not null
MDesc char 50 Not null
MLocation char 50 Not null
DEPENDENTS
Field Data Type Length Required Foreign Key
EID{PK} char 10 Not null EMPLOYEE
DeLastName char 20 Not null
DeFirstName char 20 Not null
DeMI char 4
DeGender char 1
DeBYear date
DeBMo date
DeBDay date
Relationship char 50
WorksOn
Field Data Type Length Required Foreign Key
EID{PK} char 10 Not null EMPLOYEE
PrNo char 10 Not null PROJECT
HoursPerMonth float
ProjectLocation
Field Data Type Length Required Foreign Key
PrNo{PK} char 10 Not null PROJECT
PrLocation char 50 Not null
FRIENDS
Field{PK} Data Type Length Required Foreign Key
EID1 char 10 Nut null EMPLOYEE
EID2 char 10 Nut null EMPLOYEE
USE
Field Data Type Length Required Foreign Key
EID{PK} char 10 Nut null EMPLOYEE
PrNo char 10 Nut null PROJECT
MNo char 10 Nut null MACHINE
UseDate date
SHour date
SMin date
EHour date
EMin date
HoursPerDay float
HasPhone
Field Data Type Length Required Foreign Key
EID{PK} char 10 Not null EMPLOYEE
EPhone char 10 Not null
Step by Step Conversion
From ERD to Tables
Tabular Representation of the
ER Diagram [EN2007]
STEP 1: For each regular (strong) entity type E in the
ER schema
• create a relation R that includes all the simple (and single
valued) attributes of E.
• include only the simple component attributes of a
composite attribute.
• choose one of the key attributes of E as primary key for
R.
• if the chosen key of E is composite, the set of simple
attributes that form it will together from the primary key of
R.
Step1- EDR To Relational: Strong Entity E
E
attribute-1{PK}
attribute-2
attribute-3
Primary Key attribute-3-a
attribute-3-b
attribute-4 [0..*]
/attribute-5
E
attribute-1 attribute-2 attribute-3-a attribute-3-b attribute-5
Controls
EStName
Company ECity MgrStartDate
DEPARTMENT DEPARTMENT
DNo {PK} DNo DName DLocation
DName
DLocation
MACHINE
MACHINE MNo MDesc MLocation
MNo {PK}
MDesc
MLocation
W
attribute-a attribute-1 attribute-2 attribute-3-1 attribute-3-2 attribute-5
Controls
EStNo
EStName
Company ECity MgrStartDate
DeFirstName
DeBYear UseDate
DeMI
DeBMo Start Time
DeBDay 0..1 0..1 SHour
POSITION MACHINE
Relationship SMin
End Time
0..*
PNo {PK} EHour MNo {PK}
1..* Support PName
Salary
EMin
/HoursPerDay
MDesc
MLocation
EMPLOYEE
Step-1 EDR To Relational: Weak Entity
EID {PK}
EName DEPENDENTS{W}
ELastName
EFirstName DeGender
EMI DeBDate
EAddress DeBYear
EStNo DeBMo
EStName DeBDay COMPANY
ECity Relationship
ECountry
EPhone [0..3]
EGender
EBDate
EBYear
EBMo
EBDay
/EAge
DEPENDENTS ( EID, DeLastName, DeFirstName,
DeName DeMI, DeGender, DeBYear, DeBMo,
DeLastName
DeFirstName DeBday, Relationship)
DeMI
DEPENDENTS
EID DeLastName DeFirstName DeMI DeGender DeBYear DeBMo DeBDay Relationship
EDR To Relational:COMPANY
E1 E2
E1
attribute- attribute-b attribute-c attribute-1
a
E1 E2
E1
attribute- attribute-b attribute-c attribute-1
a
E1 E2
E1 E2
attribute- attribute-b attribute-c attribute- attribute-2 attribute-3
a 1
E1-E2
attribute-a attribute-b attribute-c attribute-1 attribute-2 attribute-3
E1 1..1 0..1 E2
attribute-a{PK} attribute-1{PK}
attribute-b attribute-2
attribute-c R attribute-3
attribute-r1
S attribute-r2 T
Primary Key Foreign Key
E1
attribute- attribute-b attribute-c attribute-1 attribute-r1 attribute-r2
a
Controls
EStNo
EStName
Company ECity MgrStartDate
DeFirstName
DeBYear UseDate
DeMI
DeBMo Start Time
DeBDay 0..1 0..1 SHour
POSITION MACHINE
Relationship SMin
End Time
0..*
PNo {PK} EHour MNo {PK}
1..* Support PName
Salary
EMin
/HoursPerDay
MDesc
MLocation
Step-3 EDR To Relational - Binary 1:1 Company
EMPLOYEE
EID {PK}
DEPARTMENT
EName
ELastName 0..1 1..1 DNo {PK}
EFirstName manager
DName S
DLocation
EMI
EAddress MANAGES {R}
EStNo
EStName MgrStartDate
ECity
ECountry DEPARTMENT
EPhone [0..3] T DNo DName DLocation MgrEID MgrStartDate
EGender
EBDate
EBYear DEPARTMENT ( DNo, DName, DLocation)
EBMo
EBDay
/EAge DEPARTMENT ( DNo, DName, Dlocation, MgrEID, MgrStartDate)
EDR To Relational:COMPANY
E1
attribute- attribute-b attribute-c attribute-1
a
E1 1..* 0..1 E2
attribute-a{PK} attribute-1{PK}
attribute-b attribute-2
attribute-c R attribute-3
attribute-r1
S attribute-r2 T
Primary Key Foreign Key
E1
attribute- attribute-b attribute-c attribute-1 attribute-r1 attribute-r2
a
Controls
EStNo
EStName
Company ECity MgrStartDate
Controls
EStNo
POSITION
EStName
ECity
1..* 0..1
PNo {PK}
ECountry
PName 1..*
EPhone [0..3] JobIs
EGender
EBDate S T Salary
PROJECT
S
EBYear PrNo {PK}
EBMo PrName
EBDay PrLocation [1..*]
/EAge Relations to be modified:
EMPLOYEE (EID, ELastName, EFirstName, EMI,
EStNo, EStName, ECity, ECountry, EGender, EBYear,
EBMo, EBDay, EAge)
EBYear
EBMo EMPLOYEE (EID, ELastName, EFirstName,
EBDay PK EMI, EStNo, EStName, ECity, ECountry,
/EAge
EGender, EBYear, EBMo, EBDay, EAge)
0..1
T
Controls
1..*
PROJECT
S
PrNo {PK}
PrName
PrLocation [1..*] PROJECT ( PrNo, PrName)
R
R(attribute-a, attribute-1)
attribute- attribute1
a
Primary Key
Foreign Key
Step 5- EDR To Relational: Binary *:*
Case 2
E1 E2
1..* 0..*
att-a{PK} att-1{PK}
att-b att-2
R
att-c att-3
att-r1
att-r2
Create a new relation
R
R(att-a, att-1, att-r1, att-r2)
att-a att-1 att-r1 att-r2
Controls
EStNo
EStName
Company ECity MgrStartDate
EName
ELastName 1..*
0..* EFirstName
PROJECT
EMI
friend2 EAddress
PrNo {PK}
PrName
EStNo
PrLocation [1..*]
EStName
ECity
ECountry
EPhone [0..3]
EGender New Relations To be Created:
EBDate
EBYear WorksOn
EBMo
EBDay
Friends
/EAge
Step-5 EDR To Relational - Binary *:* Company
WorksOn {R}
EMPLOYEE
0..*
HoursPerMonth
EID {PK}
EName
ELastName 1..*
EFirstName
PROJECT
EMI
PrNo {PK}
EAddress
PrName
EStNo
PrLocation [1..*]
EStName
ECity PK FK
ECountry
EPhone [0..3]
EGender
EBDate WorksOn
EBYear
EBMo EID PrNo HoursPerMonth
EBDay
/EAge
EName
ELastName
0..* EFirstName
EMI
friend2 EAddress
EStNo
EStName
ECity PK
ECountry
EPhone [0..3]
EGender
EBDate Friends
EBYear
EBMo EID1 EID2
EBDay
/EAge
R
R(attribute-a, attribute-1)
attribute- attribute1
a
Primary Key
Foreign Key
Step 6- EDR To Relational: Binary Multi-valued
E1
att-a{PK} Case2: multi-valued attribute
att-b is a composite attribute
att-c [1..*]
att-c-1 {pk}
att-c-2
att-c-3 discriminator
Create a new relation
R R(att-a, att-1, att-c-2 att-c-3)
att-a att-c-1 att-c-2 att-c-3
Primary Key
Foreign Key
Friends friend1 EMPLOYEE 1..* 1..1 DEPARTMENT
0..* EID {PK} staff WorksFor DNo {PK}
EName 0..1 1..1 DName
0..* ELastName
EFirstName manager DLocation
friend2 EMI 0..1
EAddress
ERD MANAGES {R}
Controls
EStNo
EStName
Company ECity MgrStartDate
0..*
E3
attribute-i{PK}
attribute-ii
0..*
E3
attribute-i{PK}
PK attribute-ii
Controls
EStNo
EStName
Company ECity MgrStartDate
USE
EID PrNo MNo UseDate SHour SMin EHour EMin HoursPerDay
USE ( EID, PrNo, Mno, UseDate, Shour, Smin, Ehour, Emin, HoursPerDay )
EDR To Relational:COMPANY
After Step-7, we have the following relations:
POSITION ( PNo, PName, Salary)
MACHINE( MNo, MDesc, MLocation)
DEPENDENTS ( EID, DeLastName, DeFirstName, DeMI, DeGender,
DeBYear, DeBMo, DeBDay, Relationship)
DEPARTMENT ( DNo, DName, DLocation, MgrEID, MgrStartDate)
EMPLOYEE (EID, ELastName, EFirstName, EMI, EStNo, EStName, ECity,
ECountry, EGender, EBYear, EBMo, EBDay, EAge, DNo, PNo)
PROJECT ( PrNo, PrName, DNo)
WorksOn ( EID, PrNo, HoursPerMonth )
FRIENDS ( EID, EID2)
HasPhone ( EID, EPhone )
ProjectLocation ( PrNo, PrLocation )
USE ( EID, PrNo, Mno, UseDate, SHour, SMin, EHour, EMin, HoursPerDay )
EMPLOYEE
Field Data Type Length Required Foreign Key
EID char 10 Not null
ELastName char 30 Not null
EFirstName char 30 Not null
EMI char 4
EStNo char 5
EStName char 20
ECity char 20 Not null
ECountry char 20 Not null
EGender char 1 Not null
EBYear Date Not null
EBMo Date Not null
EBDay Date Not null
EAge int
DNo char 5 Not null DEPARTMENT
PNo char 5 Not null POSITION
DEPARTMENT
Field Data Type Length Required Foreign Key
DNo char 10 Not null
DName char 50 Not null
DLocation char 50 Not null
MgrEID char 10 EMPLOYEE
MgrStartDate Date
POSITION
Field Data Type Length Required Foreign Key
PNo char 10 Not null
PName char 50 Not null
Salary money
PROJECT
Field Data Type Length Required Foreign Key
PrNo char 10 Not null
PrName char 50 Not null
DNo char 10 Not null DEPARTMENT
MACHINE
Field Data Type Length Required Foreign Key
MNo char 10 not null
MDesc char 50 Not null
MLocation char 50 Not null
DEPENDENTS
Field Data Type Length Required Foreign Key
EID char 10 Not null EMPLOYEE
DeLastName char 20 Not null
DeFirstName char 20 Not null
DeMI char 4
DeGender char 1
DeBYear date
DeBMo date
DeBDay date
Relationship char 50
WorksOn
Field Data Type Length Required Foreign Key
EID char 10 Not null EMPLOYEE
PrNo char 10 Not null PROJECT
HoursPerMonth float
ProjectLocation
Field Data Type Length Required Foreign Key
PrNo char 10 Not null PROJECT
PrLocation char 50 Not null
FRIENDS
Field Data Type Length Required Foreign Key
EID1 char 10 Nut null EMPLOYEE
EID2 char 10 Nut null EMPLOYEE
USE
Field Data Type Length Required Foreign Key
EID char 10 Nut null EMPLOYEE
PrNo char 10 Nut null PROJECT
MNo char 10 Nut null MACHINE
UseDate date
SHour date
SMin date
EHour date
EMin date
HoursPerDay float
HasPhone
Field Data Type Length Required Foreign Key
EID char 10 Not null EMPLOYEE
EPhone char 10 Not null
Exercises
Exercise #1 : Reduce to Relations (Tables)
STUDENT
SID {PK}
SName
SDegree
SGPA
1..*
FACULTY COURSE
ENROLL {R}
0..* 1..*
FID {PK} CCode {PK}
Section
FName CName
RoomNo
FDegree CDesc
Sked
DNo CUnits
Day
StartTime
EndTime
Grade
Exercise #2 : Reduce to Relations (Tables)
COURSE
STUDENT
CCode {PK}
SID {PK} CName
SName CDesc
SDegree CUnits
SGPA Sec {PK}
1..* 0..1
Offering
1..*
FACULTY 0..* ENROLL {R}
1..* CLASS {W}
FID {PK} Grade Sec {PK}
FName
RoomNo
FDegree
Sked
DNo
Day
StartTime
EndTime
Exercise #3 : Reduce to Relations (Tables)
No partial key
PROJECT
SUPPLIER
SUPPLY {W}
1..* 0..1 ProjName {PK}
SName {PK} 1..*
Quantity ProjDesc
SAddress
ProjLeader
1..*
S-Part
0..1
0..1
S-S PART S-Proj
HOW?? PartNo {PK}
Convert the PartDesc
relationship supply to a
weak entity
Exercise #4 : Reduce to Relations (Tables)
SUPPLY PROJECT
SUPPLIER
Do-LT
Br-Offer-Acct
Br-Offer-Acct
LOAN
ACCOUNT LoanNo {PK}
1..*
ACCT-TRAN AcctNo {PK} Amount
{W} 1..*
Balance LoanType
AT-Date CUSTOME
AcctType R LT-No
AT-Type 1..*
AT-No 1..* SSN {PK} Cust-Loan
AT-Amount 1..1
1..1 CName
Cust-Acct
CAddress 0..*
1..* Do-AT 0..* CPhone
Exercise #6 : Reduce to Relations (Tables)
0 ..*
C F
1..* 0..* A B 0..*
c1{PK} f1{PK} 1..1 1..1
a1{PK} b1{PK}
c2 f2
R10 b2
c3 [1..*] a2
f3 b3 R2{R}
c4 {d/pk} a3 R1{R}
f4 r2-1 [1..*]
c5 1..* r1-1 e1
1..1
r2-2 {d}
c6 r1-2 0..1
R6 r2-3
0..1 1..*
r2-4
R4{R} I E {W}
R5 r4-1 i1 {PK} e2
0..* i2 /e3
r4-2
1..1
0..1 1..1
D R8
1..1 1..* 1..*
d1{PK}
J H {W} R7 G R3{R}
d2 R9
j1{PK} h1 g1{PK} r3-1
d3 1..* 1..*
j2 0..1 h2 0..1 g2 r3-2
d4
END … Thank You!!
75
MS ACCESS DATA TYPES
Data type Storage size Description
Any type of data may be stored
in a field of this type. No
translation of the data (for
1 byte per
BINARY example, to text) is made. How
character
the data is input in a binary
field dictates how it will appear
as output.
Yes and No values and fields
BIT 1 byte that contain only one of two
values.
An integer value between 0 and
TINYINT 1 byte
255.
MS ACCESS DATA TYPES
Data type Storage Size Description
A scaled integer
between
– 922,337,203,685,477
MONEY 8 bytes
.5808 and
922,337,203,685,477.5
807.
A date or time value
DATE 8 bytes between the years 100
and 9999.
A unique identification
UNIQUEIDENTIFIER 128 bits number used with
remote procedure calls.
MS ACCESS DATA TYPES
Data type Storage size Description
A single-precision floating-point value
with a range of – 3.402823E38 to
REAL 4 bytes – 1.401298E-45 for negative values,
1.401298E-45 to 3.402823E38 for positive
values, and 0.
A double-precision floating-point value
with a range of – 1.79769313486232E308
to – 4.94065645841247E-324 for negative
FLOAT 8 bytes values, 4.94065645841247E-324 to
1.79769313486232E308 for positive
values, and 0.
A short integer between – 32,768 and
SMALLINT 2 bytes 32,767. (See Notes)
Data type Storage size Description
A long integer between – 2,147,483,648
INTEGER 4 bytes and 2,147,483,647. (See Notes)
An exact numeric data type that holds
values from 1028 - 1 through - 1028 - 1.
You can define both precision (1 - 28)
DECIMAL 17 bytes and scale (0 - defined precision). The
default precision and scale are 18 and 0,
respectively.
2 bytes per
TEXT Zero to a maximum of 2.14 gigabytes.
character
Zero to a maximum of 2.14 gigabytes.
IMAGE As required Used for OLE objects.
2 bytes per
CHARACTER Zero to 255 characters.
character
Source Type Target Type
Java Pre-Type Java Type Java Post-Type Data Element Type
boolean bit
byte tiny integer
short small integer
int integer
long long binary
float float
double double precision
const char character
char character varying
const char * long character
char * long text
char * long var character
default long var character
Step 7- EDR To Relational: Multi-way
E1 E2
Case 1: 0..*
• Cardinality -All Many E3
• R has no attributes
attribute-i{PK}
attribute-ii
0..1
Case 2:
E3
• Mixture of many
and one cardinalities Do not include
attribute-i{PK} in the primary
• R has no attributes
attribute-ii key (whose
cardinality is
Create a new relation S one); but
include as a
S(attribute-a, attribute-1, attribute-i) foreign key
Step 7- EDR To Relational: Multi-way
E1 E2
0..1
Case 3:
E3
• All one cardinalities
• Mixture of total and
attribute-i{PK}
partial
attribute-ii Foreign key
• R has no attributes
1..1
Case 4-a:
E3
• All one cardinalities
• All total
attribute-i{PK}
participation
attribute-ii Foreign key
• R has no attributes
1..1
Case 4-b:
E3
• All one cardinalities
• All total
attribute-i{PK}
participation
attribute-ii
• R has no attributes
Drop relations E1, E2 and E3 and then create a new relation S
S(attribute-a, attribute-b, attribute-1, attribute-2, attribute-i,
attribute-ii)
Step 7- EDR To Relational: Multi-way
E1 R {R} E2
Case 5: 0..*
• Cardinality -All Many E3
• R has attributes
attribute-i{PK}
attribute-ii
Case 7: 0..1
• All one cardinalities E3
• Mixture of total and
partial attribute-i{PK}
• R has attributes attribute-ii Foreign key
C4 C5 C6
f3 f4