3. What is Entity?
• An object in a system that store information.
• Usually recognizable concepts, either concrete or abstract, such as
person, places, events.
• Example: student, restaurant, course
4. What is Attribute?
• Characteristic of an entity or view object.
• Correspond to a database column or independent of a column.
5. Entities for PERODUA Car Service Centre
• peroOwner
• peroCar
• loginDetail
• peroService
• peroAppointment
10. How the tables in the scenario are related to each
other using primary and foreign keys
11. Relationship Between Tables
Table Cardinality Primary Key Foreign Key Assumption
peroOwner - ownerID
peroCar - peroCarID
peroCarOwner - peroCarID+ownerID PeroCarID
ownerID
peroCar and
peroCarOwner
One to One One car is belonged
to only one owner
peroOwner and
peroCarOwner
One to Many One owner may
have one or many
car owners
12. Relationship Between Tables
Table Cardinality Primary Key Foreign Key Assumption
loginDetail - loginID ownerID
peroOwner and
Account
One to Many One owner may
login one or many
times
account and
peroOwner
One to One One account has
only one owner
13. Relationship Between Tables
Table Cardinality Primary Key Foreign Key Assumption
peroService - peroServiceID
peroCarService peroAppID+peroSer
viceID
peroAppID
peroServiceID
peroService and
peroCarService
One to Many One service may
have one or many
appointments
peroCarService and
peroservice
One to One One appointment is
related with only
one service
14. Relationship Between Tables
Table Cardinality Primary Key Foreign Key Assumption
peroAppointment - peroAppID
peroCarAppointment peroAppID+PeroCarID PeroAppID
PeroCarID
peroCar and
peroAppointment
One to Many One car may be
able to make one
or many
appointments
peroAppointment
and peroCar
One to One One appointment
is related with only
one car
16. Entity Relationship with reasoning Attributes Constraints
peroCar 1:M(One car may schedule one or many
appointments). If a car is accidently crashed and it
is removed from appointment table, the associated
car and appointment records will be automatically
deleted from perocarappointment table by enforcing
cascade delete option of referential integerity
peroCarID(PK)
peroCarModel
peroYear
peroColor
peroTransmission
peroFuelType
peroMileage
peroEnginePower
peroEngineType
peroCarNo
peroRegNo
peroCarID(PK)
appoint (R) M:1 peroAppID
peroCarID
Composite Primary Key
peroAppoinment 1:1(One appointment must be related with only one
car) If an appointment has been cancelled in
peroappointment table, the corresponding car and
appointment records from perocarappointment table
will be automatically removed
peroAppID(PK)
peroAppDateTime
peroEmployee
peroAppStatus
peroAppID(PK)
Referential Integrity
17. P2 Design a relational database for a
specified user need
18. Plan the tables
• peroOwner
• PeroCar
• peroCarOwner
• loginDetail
• peroService
• peroAppointment
• peroCarService
• peroCarAppointment
32. M1 Explain referential integrity and the purpose
of primary keys in building the relationships
between tables
33. Purpose of Primary Key
Table Primary Key Purpose of P.K Foreign Key Purpose of F.K
perowner ownerID To uniquely identify
each owner record
perocar peroCarID To implement data
integrity
perocarowner (peroCarID+
ownerID) Composite
Key
To implement a
relationship between 2
tables (owner & percar)
in a relational database
peroCarID
ownerID
Referential Integrity is
not allowed to enter a
record in foreign key
table(peroowner) if that
record is not included in
primary key table(owner,
peroCar)
…..To Continue NEXT SLIDE
34. Purpose of Primary Key
Table Primary Key Purpose of P.K Foreign Key Purpose of F.K
logindetail loginID Ensure row-level
accessibility
ownerID If the user attempts to
enter a record in the
logindetail table using
an ownerID that is not
found in the owner
table, the database will
reject that entry and
display a warning
message
peroservice peroServiceID To uniquely identify
each owner record
…..To Continue NEXT SLIDE
35. Purpose of Primary Key
Table Primary Key Purpose of P.K Foreign Key Purpose of F.K
peroappointment peroAppID To implement data
integrity among the
appointment records
perocarservice (peroAppID+
peroServiceID)
Composite Key
Combination of columns
is selected to guarantee
that two services never
have the same
appointment unique
value
peroAppID
peroServiceID
Due to the properties of
referential integrity, all
records have ACID
properties like Atomicity,
Consistency, Isolation
and Durability
perocarappointment (peroAppID+
peroCarID) Composite
Key
Combination of columns
is selected to guarantee
that two cars never have
the same appointment
unique value
peroAppID
peroCarID
The enforce referential
integrity among the
tables, cascade delete
cascade update option
are provided for foreign
key tables
36. Explain how you can create primary key in a
table using script or phpMyAdmin for the above
scenario
106. Find and display Owner, Car & Service
Appointments for a particular Owner
based on owner email and for service
appointment within the next 1 month
107.
108.
109. P6 Include an advanced feature in a
database design
126. No Test Objective Test Case Expected Result Actual
Result
Pass/Fail
1 Include test to ensure
referential integrity
If the user attempts to enter a
record in the logindetail table
using ownerID that is not
found in the table
The database will reject that entry
and display warning message
Successful Pass
If a car record is deleted from
car table
The associated peroCarID,ownerID,
peroAppID and peroCarID will
automatically be removed from
perocarowner table and
perocarappointment table
respectively.
2 Include test to ensure
default field
Set “CURRENT_TIMESTAMP” as
default for createdOn field in
perocar table
Successful Pass
127. No Test Objective Test Case Expected Result Actual Result Pass/Fail
To ensure auto
generated fields are
working as expected
Set peroCarID as
AUTO_INCREMENT services
table
Successful Pass
3 To ensure field sizes
meets requirements
If I enter peroColor field over
15 characters
If I enter contactNo field over
20 characters
That peroColor data is not
allowed to save into the database
That contactNo is not allowed to
save into the database
Successful
Successful
Pass
Pass
128. No Test Objective Test Case Expected Result Actual
Result
Pass/Fail
4 Null values are
handled for non-
mandatory fields
If I leave as blank for non-
mandatory fields in owner
register form
Successful Pass
129. P4 Create features in data entry forms to
ensure validity and integrity of data
171. No Requirement Query Used Database Meets
Requirements
(YES/NO)
Comments
1 Users able to register
themselves
Users able to register
themselves
Yes Figure 1
Yes Figure 2
Yes Figure 3
175. No Requirement Query Used Database Meets
Requirements
(YES/NO)
Comments
2 Users are able to login to the
portal
Yes Figure 4
3 Users are able to register their
cars
Yes Figure 5 & 6
176. No Requirement Query Used Database Meets
Requirements
(YES/NO)
Comments
4 Users are able to Add Cars Yes
Figure 5 & 6
Users are able to Delete Cars Yes Figure 7 & 8
186. No Requirement Query Used Database Meets
Requirements
(YES/NO)
Comments
5 Delete existing, unexpired
appointment for their car
servicing
Yes Figure 12 & 13
187. Figure 12 & 13
Before Deleting After Deleting
188. No Requirement Query Used Database Meets
Requirements
(YES/NO)
Comments
6 To count car quantity
based on owner ID
Yes Figure 14
To count number of
appointment times based
on carID
Yes Figure 15
197. TNF (Eliminate any column reference in reference data that
are not dependent on the primary key. Only foreign key
columns should be used to referenced another table, and no
other columns from the parent table should exist in the
referenced table)
199. POTENTIAL ERRORS IN THE
DESIGN AND CONSTRUCTION
OF DATABASE THAT CAN BE
AVOIDED
200. 1) Accidental deletion of fields
• When a database is in use, you may find it really easy to accidently delete data which
could mean allot of stress.
• One main way to AVOID this would be to make sure that back-ups are made of the data,
so whatever the matter the data will not be completely lost. However, it is very annoying
when data becomes deleted because it takes allot of time and effort to retype the data.
• The best way to stop accidental deletion is to set the database to only the designer can
manipulate it, so anyone using the database without authorisation cannot manipulate
and is only able to read the database with no risk of deletion.
201. 2) Incorrect data types
• Incorrect data type issues can occurs when an unmatched data type is used.
• An example would be, a field called ‘fees’ in a table in a database, it will go wrong if a
‘text value’ is inserted instead of a ‘numerical value’ like ‘two hundred’ instead of ‘200’.
• This can be avoided as you can tell the database to only allow numerical values to be
inputted within that field so this error won’t occur again. The database won’t allow
anything inputted other than numbers.
202. 3) Renaming Incorrectly
• Renaming something or someone incorrectly on a database can be a huge mistake,
hugely if it were to happen to be a bank.
• This is mostly done by human error as a typo or misheard information.
• This means if the error isn’t spotted then it will not be sorted out; so a way to sort out
the problem is by double checking the information given and typed.
203. 4) Validation
• Validation within computers is on par with people verification checks, but checks the data to see if the data
entered is sensible and reasonable.
• When a user puts information in to a database which might not be right then the computer will do
validation checks to see a match between the users input and information given to the database to run
though a list of checks.
• Example: The database is given a set of rules to run by which would be >=18 which means that nothing
under the number (age) is allow to carry on to the next step. So if someone that is the age of 17 or under
will not be allowed to move forward. So as you can see this helps to validate information allowing and
disallowing data which helps to organise the database making sure all the data is correct.
204. 5) Null Values
• The meaning of a null value equals to “nothing there” within a database.
• This would be a big problem with the database as the database will not be able to work properly
as it doesn’t understand what it is told and might cause other errors within the database.
• If the data base has not been set to understand the null values it would carry on to the next step,
but to prevent this from happening you can the use of a validation rule. The validation rule will
work to stop the null value from happening like in an ‘online application form’ where if no value
were to be entered then a user wouldn’t be able to carry on to the next step; the validation rule
will work in the same way to stop the null value from arising and missing values from happening.