Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

PMU- MIS Department - Database Management - Handout#1

Assignment 1
Points: 10 %
Group: Maximum 3 members
Due date: Oct 10, 2023
Late submission: Oct 17 (with a 20% deduction of the grade)

Guidelines and Instructions:

1. Only soft copy in PDF to the Black board (One student from the group need to
submit). Use the cover page for your names and IDs.

Cover Page

Name ID
1.

2.

3.

2. The following example of ship and captain is just an example. You


must choose and complete it for different entities with different
attributes (columns names). For instance, student, teacher course etc.
or customer, product, sale etc.
3. Two groups will not use the same entities and attributes names.
Therefore, chose an organization name such as school or bank etc. and
also chose your entities names and discuss with the instructor before
to start work on it.
___________________________________________________________

Creating a database Using Microsoft Access


Muhammad Rafiq 1
PMU- MIS Department - Database Management - Handout#1

Microsoft Access is a Database Management System (DBMS).

It allows us to create tables, fields, primary keys and relationships. It


also allows us to make rules for what kind of data a field can hold
e.g. the Gender field could have the following rules:

It is required – a gender must be entered


Its Data Type is Text
Its Field Size is 1
It can only hold a value of M or F (Validation Rule)

It also helps us to Query (question) the database (e.g. which students


in year2 are from UAE and were born before 1989?).

It also helps us to create Forms and Reports so that we can show


information from the database in a more professional way than by just using
queries.

We will now build a database for the Ship and Captain situation. This
is a One-To-One relationship:

1 1
Ship Captain

Muhammad Rafiq 2
PMU- MIS Department - Database Management - Handout#1

1. Start the Access program.


2. Click on New Blank Database

3. Give the database a meaningful name:

4. Create it in a specified folder:

Muhammad Rafiq 3
PMU- MIS Department - Database Management - Handout#1

Note:
This will create a file with an extension of .accdb.
5. Change to Design view:

6. Name your first table and save it:

Muhammad Rafiq 4
PMU- MIS Department - Database Management - Handout#1

Muhammad Rafiq 5
PMU- MIS Department - Database Management - Handout#1

7. Create a Primary Key field.


In this example the Field Name is CaptainID and the Data Type is
Text and the Field Size is 10. It is also the Primary Key.

8. Enter the other fields and choose appropriate Data Types


for each.
Save the table:

9. Create a Ship table:

Muhammad Rafiq 6
PMU- MIS Department - Database Management - Handout#1

Muhammad Rafiq 7
PMU- MIS Department - Database Management - Handout#1

10. Now add the Foreign Key field to the Captain table and save
this. The Foreign Key is ShipID.
Note:
The Foreign Key field should have the same Field Name, Field Type
and Field Size as it has in the Ship table:

Muhammad Rafiq 8
PMU- MIS Department - Database Management - Handout#1

11. Because this is a one-to-one relationship we must do one extra


thing.
Change the Indexed property for the Foreign Key to Yes (No
Duplicates).
Note:
We only have to do this for one-to-one relationships but not for one-
to-many relationships.

Muhammad Rafiq 9
PMU- MIS Department - Database Management - Handout#1

12. Close the Captain and Ship tabs:

13. Now we can add the relationship to the database.


Click the Database Tools tab then click Relationships:

Add the tables:

Muhammad Rafiq 10
PMU- MIS Department - Database Management - Handout#1

Drag and drop ShipID from the table where it is the Primary
Key to the side where it is the Foreign Key:

Drag
And
Drop

14. First make sure that a One-To-One relationship is going to


be created – if it isn’t make sure that you created the index (go back to
11 above).

Check Enforce Referential Integrity and click Create:

Muhammad Rafiq 11
PMU- MIS Department - Database Management - Handout#1

Check that you have a One-To_One relationship:

Referential Integrity

Why did we check Referential Integrity for the relationship?


With this checked, Access will make sure that a ShipID that is entered
into the Captain table is a ship that exists in the database. It does this by
automatically checking to see if the ship is in the Ship table – if it isn’t then
it will display an error message.

Before you enter data records, check that you have created the
Relationship correctly.

Muhammad Rafiq 12
PMU- MIS Department - Database Management - Handout#1

15. Enter the following data records into your tables:

ShipID ShipName Passengers Cargo Launched Value


S3 Titanic 2000 500 1/1/1905 30
S7 Britanic 2000 6/7/1970 20
S12 Australis 1500 3/8/1985 55

CaptainID FirstName Family Other Gender DOB Salary Joined Married? ShipID
C5 David Campbell M 27/12/1948 50000 1/4/1985 Y S3
C8 Fatima Al Shehhi Sultan F 4/11/1978 20000 5/7/1999 N S7
C9 Zainab Yousef Abdulla F 3/8/1980 24000 6/3/2000 Y

16. Try to enter the following record:

CaptainID FirstName Family Other Gender DOB Salary Joined Married? ShipID
C5 David Campbell M 27/12/1948 50000 1/4/1985 Y S7

What happens and why?


This is showing an error message as a duplicate value.

Muhammad Rafiq 13
PMU- MIS Department - Database Management - Handout#1

17. Try to enter the following record:

CaptainID FirstName Family Other Gender DOB Salary Joined Married? ShipID
C11 Hajar Al Shehhi Saeed F 21/10/1966 32000 11/7/1990 N S12

What happens and why?


This is inserted in the table.

18. Try to enter the following record:

CaptainID FirstName Family Other Gender DOB Salary Joined Married? ShipID
C12 Mouza Al Saeed F 2/12/1975 40000 1/11/1986 Y S15
Mansoori

What happens and why?


This is showing error that a related record is required in the table ship.

Muhammad Rafiq 14

You might also like