0% found this document useful (0 votes)
10 views4 pages

Databases Worksheet 1 Entity Relationship Mod

This document is a worksheet focused on entity relationship modeling in databases, covering tasks such as defining entities, types of relationships, and creating entity relationship diagrams. It includes practical exercises using MS Access to add records, designate primary keys, and establish relationships between tables. Additionally, it provides examples and prompts for completing an order form and designing database structures.

Uploaded by

Hamza Omar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views4 pages

Databases Worksheet 1 Entity Relationship Mod

This document is a worksheet focused on entity relationship modeling in databases, covering tasks such as defining entities, types of relationships, and creating entity relationship diagrams. It includes practical exercises using MS Access to add records, designate primary keys, and establish relationships between tables. Additionally, it provides examples and prompts for completing an order form and designing database structures.

Uploaded by

Hamza Omar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Worksheet 1 Entity relationship modelling

Unit 11 Databases and software development

Worksheet 1 Entity relationship modelling


Task 1: Entity relationship diagrams
1. What is an entity in the context of databases?

2. The relationship between two entities may be one of three types, or degrees.
What are the three degrees of relationship between entities?

3. Draw entity relationship diagrams for each of the following pairs of related entities:
(a) Dentist and patient

(b) Student and teacher

(c) UK citizen and UK Passport

(d) Product and component

1
Worksheet 1 Entity relationship modelling
Unit 11 Databases and software development

4. A company makes a range of kitchen utensils which they sell online. They record details of
their customers, products and orders received in a database. An order may be for several
products.
Complete the E-R diagram to show all the relationships between all the entities.

Customer Product

Order OrderLine

5. Complete the design of the order form shown below. Enter some data for a sample order
for three different products.

(Customer details) KitchenTools Ltd


(address)

Order number:

Date:

Line Qty Product code Description Unit Price Total price

Total:

On your order form, what are the primary key fields of the entities Customer, Product, Order,
OrderLine?

2
Worksheet 1 Entity relationship modelling
Unit 11 Databases and software development

Task 2
This is a practical exercise using MS Access. You are going to be working with the database
RevisionSubs_stage1.accdb. This consists of three tables called tblCustomer, tblProduct,
tblSubscription.

Step 1: Add some records to the database

1. Load Access and find the database called RevisionSubs_stage1.accdb.


2. Open the database. Double-click the table tblCustomer and it will appear in Datasheet
View. In this view, you can enter, delete or amend data.
3. Add the following record to the table tblCustomer
C444 Mr Basil Brown [email protected]
4. Add the following two records to tblSubscription
S1400 21/03/2016 20/06/2017 C444 P47
S1401 21/03/2016 20/06/2017 C444 P36

Step 2: Designate primary key attribute in each table


The structure of a table is defined when it is first created. These tables have been defined
without primary keys, so the structure needs to be amended to define one or more fields in
each table as a primary key.
5. Click tblCustomer. Click View at the left hand end of the toolbar underneath the
main menu, and select Design View.
6. Click the custID field name. Now click the Primary key icon in the toolbar. A
key symbol appears next to the field name.
7. In tblProduct, make productID a key field.
8. In tblSubscription, make subID a key field.
9. Right-click the tabs for each table in turn, and choose Close each time. Answer Yes when
asked if you wish to save the table.

Step 3: Creating relationships between the tables


We now need to create the one-to-many relationship between tblCustomer and
tblSubscription, and the one-tp-many relationship between tblSubscription and
tblProduct.
10. Click Database Tools in the main menu. Then double-click the Relationships
icon in the toolbar.

11. A “Show table” window opens. Click each table in turn and click Add. Close the window and
you will see the three tables displayed. Click and drag to put tblSubscription in the middle.

3
Worksheet 1 Entity relationship modelling
Unit 11 Databases and software development

12. To create a relationship, you drag the primary key field from the “one” side to the
corresponding field in the “many side of the related table. Drag CustID from tblCustomer
table to custID in tblSubscription.
13. A window appears. Click the box next to Enforce referential Integrity. This will ensure that
you cannot create a record in tblSubscription for a customer who does not exist in
tblCustomer. Now click Create.
If there is already data in tblSubscription which refers to a non-existent customer, you will
see this message:

If you get this message, you need to take another look at the records in tblCustomer and
tblSubscription and make sure you have all the necessary records on tblCustomer.
14. Create the relationship between tblProduct and tblSubscription. Remember to enforce
referential integrity.
Now the relationships will be shown:

15. Save and close the database.

You might also like