Exploring CAT Grade 12 - Hardware HTML Normalisation
Exploring CAT Grade 12 - Hardware HTML Normalisation
Grade 12
The title is a field that is used in the header.
The title will be covered by the front cover image.
Exploring CAT: Grade 12
Copyright © 2021
First Edition
All rights reserved
Further copies of this book and the books in this series may be ordered from [email protected] or
purchased online at www.funworks.co.za.
Exploring IT series also available at www.funworks.co.za.
Acknowledgements
The front cover and illustrations were inspired by the creative genius of Caroline Hills.
Thanks to Funworks publishers for assistance with editing this book.
Thanks to Kiara White for her incredible front cover design of both the Exploring IT and Exploring CAT
series.
Dedications
For my late mother, Leah, with all my Love.
Gary Blieden
For Andy, Robyn and Zachary – Love you to the moon and back, a thousand times, Mom.
Lyneth Crighton
Table of Contents
i
CHECK POINT 1........................................................................................................................ 25
EXERCISE 1 .............................................................................................................................. 27
EXERCISE 2 .............................................................................................................................. 28
EXERCISE 3 .............................................................................................................................. 29
EXERCISE 4 .............................................................................................................................. 30
ii
EXERCISE 7 ..............................................................................................................................51
EXERCISE 8 ..............................................................................................................................52
8.11 A More Complex Example – Running Club ..........................................................................53
8.11.1 Identify the Tables ........................................................................................................53
8.11.2 Give each Table a Primary Key ....................................................................................53
8.11.3 Analyse the Relationships Between the Tables ............................................................54
8.11.4 Link the Tables Using the Primary and Foreign Keys ....................................................54
8.11.5 Populate the Tables with Data ......................................................................................54
8.11.6 Refine the Tables to Eliminate Redundancy and Extra Data .........................................55
8.11.7 Apply Normalisation Rules ............................................................................................57
8.12 Referential Integrity ..............................................................................................................58
ACTIVITY 2 ................................................................................................................................58
8.12.1 Implement Referential Integrity in MS Access ...............................................................58
8.12.2 Check Referential Integrity ............................................................................................59
ACTIVITY 3 ................................................................................................................................60
8.13 Alternative Method of Normalisation ....................................................................................60
8.13.1 Characteristics of Normal Forms ...................................................................................60
8.13.2 Dependencies ...............................................................................................................60
8.13.3 Partial Dependency ......................................................................................................61
8.13.4 Transitive Dependency .................................................................................................61
CHECK POINT 2 ........................................................................................................................61
8.14 Normalising a Database to Third Normal Form ....................................................................62
8.14.1 First Normal Form (1NF) - it is not all it is cracked up to be ...........................................62
8.14.2 Second Normal Form (2NF) ..........................................................................................62
8.14.3 Third Normal Form (3NF) ..............................................................................................64
ACTIVITY 4 ................................................................................................................................64
EXERCISE 9 ..............................................................................................................................65
https://medium.com/computing-technology-with-it-fundamentals/system-hardware-component-motherboard-8e3d44e29f74
• Repairs. Consider, due to load shedding, your power supply blows a fuse and your computer no
longer has electricity. In the early days of personal computers, the whole computer would have to
be sent in for repairs. This would lead to disruptions in your use of the computer (although it would
be a great excuse for not having completed your homework). In the modern computer, it is a
simple task to remove the offending power supply and replace it with a working unit.
• Upgrades. Modular Design simplifies the upgrading of the computer with better hardware. For
example, a gamer who wants to play extensive video games can buy a powerful desktop (fast
multiple processors with large cache and lots of RAM) but will need to include a high end card
designed for the gaming needs.
• Flexibility. Modular design allows for a variety of components to be added to the mother board
depending on the user's needs. The CPU, amount of RAM, secondary storage and graphics card
all contribute to the type of computer the user can choose. Laptops, tablets and mobile phones are
not as easy to upgrade and repair as their parts are highly integrated and are not easily
removeable.
1.2.2 RAM
RAM is the main memory in chips on modules attached to
dedicated slots on the motherboard. RAM stores the programs
currently in use and the data associated with them.
The type of RAM used is commonly Double Data Rate (DDR)
SDRAM.
https://www.crucial.com/usa/en/differences-among-ddr2-ddr3-and-ddr4-memory
As SSDs become more affordable, there are a variety of SSDs available. We will discuss M.2, PCIe
NVMe and SATA SSDs.
https://www.performance-computer.com/learn/ssds-compared/
NVMe SSDs produce a significant increase in speed over SATA SSDs. By upgrading a mechanical hard
drive to an SSD increases performance in tasks from boot speeds to file load speeds; however,
upgrading to an NVMe SSD will
produce even more significant
performance gains. Most modern
motherboards support NVMe
connections via the PCIe bus, but
some older boards provide a M.2
slot connected to the SATA bus
limiting the speed of the SSD
drive. To achieve these speeds
from your NVMe SSD, make sure
your operating system is installed
on the SSD drive together with
frequently used programs, games
and data.
https://www.performance-computer.com/learn/ssds-compared/
https://www.tutorialspoint.com/computer_
fundamentals/images/keyboard.jpg
Mouse The most popular pointing device. Most have Select icons,
a have a left and right button along with a menus,
scroll wheel to allow the user to select icons dropdown
on the screen. Laptops provide a track pad boxes.
to serve the same purpose as a mouse.
Most mobile devices have touch screens
where users can select icons.
https://www.tutorialspoint.com/computer_
fundamentals/images/mouse.jpg
https://www.tutorialspoint.com/computer_
fundamentals/images/scanner.jpg
https://cdn.shopify.com/s/files/1/0005/2907/2172/
products/51o6le6JPVL._AC_SX466_1024x.jpg
?v=1587314783
https://www.famoco.com/wp-
content/uploads/2019/07/product-table-FP201-
fingerprint.jpg
https://www.tutorialspoint.com/computer_
fundamentals/images/microphone.jpg
https://m.media-
amazon.com/images/I/4161GwR8l4L.jpg
https://in.toshibaaudio.com/wp-
content/uploads/sites/4/2019/03/game-blue-1-
600x600.jpg
https://www.tutorialspoint.com/computer_fundamentals/computer_input_devices.htm
• screen size,
• aspect ratios,
• resolution, and
• refresh rate.
Screen size is measured diagonally across opposite corners in
inches. Laptops have screens are usually 15", monitors
normally range between 17” and 43” but some monitors can be
up to 80". Screen resolution is the number of pixels on a
screen measured in width and height.
https://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Display_size_measurements.png/220px-
Display_size_measurements.png
https://cdn5.vectorstock.com/i/1000x1000/54/64/icon-monitor-sizes-vector-18095464.jpg
If you pack more pixels in the same size monitor with the same aspect ratio, the image will be sharper
and clearer since there are more pixels are packed into the same aspect ratio. Ultra-wide monitors are
useful as their extra width can be used to view two applications side by side on one monitor instead of
using two separate monitors.
Refresh rate is the number of frames that are displayed in a second. Monitors with a high refresh rate
require a graphics card and are usually necessary for high-end users like gamers.
There are many different types of monitors available. The monitor that you choose is usually dependant
on three categories:
• general or business use monitors are found at home or work offices and display Microsoft Office
applications, web browsers, or computer programs that do not need graphics processing. These
monitors are fairly low in price and the PC will not need a graphics card.
• professional visuals such as a digital artist, require monitors that that display the images in the
correct colour and to a higher resolution so that the finished product will look similar on other
screens. These professionals work on applications such as Adobe Photoshop for image editing or
Corel VideoStudio for video editing.
• gaming requires monitors with a high refresh rates and a PC with a powerful graphics card.
https://www.newegg.com/insider/how-to-choose-the-best-computer-monitor-buying-guide/
1.5.2 Printers
When choosing a printer many factors need to be considered since there is a large variety of printers
available each suitable to a specific situation. It goes without saying that documents should only be
printed if absolutely necessary to save the environment. Before settling on a printer, the purpose of the
printer needs to be considered. Is the printer for home or small office use, or a large office? Will the
nature of the business change which could influence printing features and functions?
https://mobile.smallbusinesscomputing.com/imagesvr_ce/9832/Epson%20ET-4550%20EcoTank.jpg
https://99designs-blog.imgix.net/blog/wp-content/uploads/2019/07/DPI-RESOLUTION.jpg
Monitors, television screens, digital cameras and scanners use a combination of Red Green Blue (RGB)
light to produce a variety of colours. When all are combined white is produced. Printers use Cyan
Magenta Yellow and Black (CMYK) in "4-color process printing". When all four pigments are combined
https://99designs-blog.imgix.net/blog/wp- https://99designs-blog.imgix.net/blog/wp-
content/uploads/2019/06/RBG-2- content/uploads/2019/06/CMYK-
column.png?auto=format&q=60&fit=max&w=930 915x915px.png?auto=format&q=60&fit=max&w=930
• Laser printers use toner unlike inkjet printers which use ink. Toner tends to last longer than ink
reducing the running cost of the printer.
• The initial cost of an inkjet printer is usually quite cheap, but the cost of the cartridges can be more
expensive. If you have low printing volumes, an inkjet can be more cost effective.
• Inkjet printers are more suitable for printing photos and color documents and laser printers are
more suitable for printing documents. There are colour laser printers available but are more costly.
• A laser printer would be a more cost effective option if you have high printing volumes since it will
be cheaper when it comes to the average cost per page.
• Inkjet printers are usually smaller and take up less space which can be advantageous for a small
home office.
https://introstat.co.za/news/tips-for-choosing-the-right-printer-for-your-needs/
https://756388.smushcdn.com/1373136/wp-content/uploads/2019/05/Connect-printer-to-router.jpg?lossy=1&strip=1&webp=1
Some printers have USB ports allowing a user to print from a flash drive that is plugged directly into the
printer.
https://www.equinoxsdrones.com/blog/10-major-pros-cons-of-unmanned-aerial-vehicle-uav-drones
1.8.1.2 Disadvantages
• Privacy and spying– drones can be used to trespass or spy on a group or individual's privacy.
Drones are small and are fairly quiet making them difficult to notice. They are used by paparazzi to
photograph celebrities and by criminals to track their targets. The rules regarding regulation of
drone movement and property protection from aerial trespassing need to be clarified.
• Vulnerable to wild animals - drones are frequently attacked by wild animals such as large flying
birds like eagles. Poachers make use of drones to locate animals for exotic trade in rhino horn,
elephant tusks and pangolin scales amongst others.
• Easy to hack - hackers can take control of the drone's central control system to access private
information, corrupt or damage the files, and leak data to third parties.
• Weather dependant - drones are more vulnerable to weather conditions compared to traditional
aircraft.
https://www.equinoxsdrones.com/blog/10-major-pros-cons-of-unmanned-aerial-vehicle-uav-drones
CHECK POINT 1
ACTIVITY 1
In Notepad++, create a new document with the file name tables.html.
Save the document in LU 5 of the Learner Files folder.
<body>
<table border = "1">
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
</body>
</html>
Open tables.html in a web browser to see that the webpage is created with two rows and two
columns.
<head>
<title>HTML Table Header</title>
</head>
<body>
<table border = "1">
<tr>
<th>Column 1 Heading</th>
<th>Column 2 Heading</th>
</tr>
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 1, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
</body>
</html>
Save the document as headings.html in LU 5 of the Learner Files folder.
Open headings.html in a web browser to see that the table has a row of headings included above
the two rows.
ACTIVITY 3
Change the Cellpadding and Cellspacing Attributes
Using headings.html in Notepad++, add the code in bold to change the cell padding and cell
spacing.
<html>
<head>
<title>HTML Table Cellpadding</title>
</head>
<body>
<table border = "1" cellpadding = "5" cellspacing = "5">
<tr>
<th>Column 1 Heading</th>
<th>Column 2 Heading</th>
</tr>
<tr>
<td>Row 1, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
</body>
</html>
Save the document as cellpad.html in LU 5 of the Learner Files folder.
Open cellpad.html in a web browser to see there is a space between each cell in the table (cell
spacing) and there is a space between the text and the border of each cell (cell padding).
ACTIVITY 4
Merge Rows and Columns Using Colspan and Rowspan Attributes
Using cellpad.html in Notepad++, add the code in bold to change the cell padding and cell
spacing.
<html>
<head>
<title>HTML Table Colspan/Rowspan</title>
</head>
<body>
<table border = "1">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
<tr>
<td rowspan = "2">Row 1 Cell 1</td>
<td>Row 1 Cell 2</td>
<td>Row 1 Cell 3</td>
</tr>
<tr>
<td>Row 2 Cell 2</td>
<td>Row 2 Cell 3</td>
</tr>
<tr>
<td colspan = "3">Row 3 Cell 1</td>
</tr>
</table>
</body>
ACTIVITY 5
Change the Table's Border Colour and Background
Using columnspan.html in Notepad++, add the code in bold to change the colour of the cell
borders and the table background.
<html>
<head>
<title>HTML Table Background</title>
</head>
<body>
<table border = "1" bordercolor = "red" bgcolor = "yellow">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
<tr>
<td rowspan = "2">Row 1 Cell 1</td>
<td>Row 1 Cell 2</td>
<td>Row 1 Cell 3</td>
</tr>
<tr>
<td>Row 2 Cell 2</td>
<td>Row 2 Cell 3</td>
</tr>
<tr>
<td colspan = "3">Row 3 Cell 1</td>
</tr>
</table>
</body>
</html>
Save the document as background.html in LU 5 of the Learner Files folder.
Open background.html in a web browser to see that the table's background is yellow, and all the
borders are red.
<head>
<title>HTML Table Width/Height</title>
</head>
<body>
<table border = "1" width = "400" height = "150">
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
</body>
</html>
Save the document as tablesize.html in LU 5 of the Learner Files folder.
Open tablesize.html in a web browser and check that the table's width and height has increased
although the size of the text has remained the same.
NOTE: Changing the width or height of the table does not increase the size of the text in the table.
<head>
<title>HTML Table Caption</title>
</head>
<body>
<table border = "1" width = "60%">
<caption>This is the caption</caption>
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
</body>
</html>
Save the document as captions.html in LU 5 of the Learner Files folder.
Open captions.html in a web browser to see that the table has a caption and is 60% of the web
browser window.
Click the Minimise button (Google Chrome) or Restore Down button (Windows Edge) in the top
left hand corner of the browser window to reduce the size of the window.
Check that the table automatically adjust to 60% of the smaller window.
Centre the Table
Add the code in bold to centre the table in the browser window:
<html>
<head>
<title>HTML Table Caption</title>
</head>
<body>
<table border = "1" width = "60%" align="center">
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
</body>
</html>
Save the document and then open it in a web browser to check that the table has been centred.
CHECK POINT 1
There are errors in the code, since the web page displays as follows:
6.1. Suggest a change to the code so that all the text in the body section will display in Arial font.
6.2. Suggest a change to the code so that the text “How to code a webpage using HTML” will NOT
appear formatted as a heading.
6.3. Where will the text “Web Design” appear when the page is displayed in a browser?
7. A website was designed using the following code:
<table border=“10”>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
<tr>
<td>Cell 3</td>
<tr>
</table>
8.
8.1. How would you correct the highlighted (bold) line (the third line of code)
so that the table will be displayed as shown alongside?
8.2. Suggest a change in code so that the table has a border colour of blue and a background
colour of yellow.
1. You have been asked to create a webpage for your school website that lists the public holidays in
South Africa in a table. In Notepad++, create a new webpage.
2. Save the webpage with the name sapublicholidays.html in LU 5 of the Learner Files folder.
3. Create a heading "South African Public Holidays" in the table as follows:
3.1. Heading level 1.
3.2. Text colour red.
3.3. Text centred.
4. Add the following rows table in the body of the page:
The updated list of public holidays for the current year can be found on the following webpage:
https://www.gov.za/about-sa/public-holidays
5. Format the table as follows:
5.1. Table width must be 70% of the webpage.
5.2. Table borders must be set to 2.
5.3. Table cell spacing must be set to 3.
5.4. Table cell padding must be set to 3.
6. Save and close the webpage in LU 5 of the Learner Files folder.
7. Open sapublicholidays.html in a web browser to see that webpage is coded correctly.
1. You have been asked to create a page to advertise the WildEarth live safaris. In Notepad++,
create a new webpage.
2. Save the webpage with the filename mywildearth.html in LU 5 of the Learner Files folder.
2. Add a title to the page to read “WildEarth LIVE”.
3. Modify the background colour of the page to be “#e1d4b3”.
4. Add an image to the website as follows:
4.1. Add the image logo.png to the top of the page.
4.2. Set the image to hyperlink to: https://wildearth.tv/live-safaris/
5. Add the following rows to the table in the body of the page:
Monday to Sunday
LIVE Safaris Sunrise Safari Central African Time (CAT) 05:30am – 09:00am
Sunset Safari Central African Time (CAT) 15:30pm – 19:00pm
1. A web page has been created to provide facts about the most endangered turtle species, the
threats faced by them and the ways to save the turtles. In Notepad++, open the incomplete
save_us.html webpage, in LU 5 of the Learner Files folder. Question numbers are inserted as
comments in the coding as guidelines to show approximately where the answer(s) should be
inserted.
2. Add HTML code so that the text "Save Sea Turtles" appears in the browser tab.
3. Change the size of the horizontal lines that comes within the heading “7 Things You Can Do To Save
Sea Turtles” to 6.
4. Insert the image baby_turtle.jpg after the heading “7 Things You…” so that the width and the height
of the image is 100 and 45 percent and the text “Baby Turtle” to display if the image does not
display in the browser.
5. Change the word “SEVEN” in the first paragraph to bold.
6. Change the unordered list displayed after the first paragraph to a square pattern bullet.
7. Insert a caption at the end of the table displayed in the webpage so that it displays “Table 1: List Of
Endangered Turtle Species”.
8. Change the heading “Most Endangered…” so that it becomes the heading for the whole table.
9. Make the following changes to the second row of the table containing the headings “Turtle Name”
and “Scientific name” so that:
9.1. The row colour is green.
9.2. The font colour is white for both the headings.
10. Correct the hyperlink tag created to the word “SEETurtles.org” found in the last paragraph so that it
links to the “www.SEETURTLES.ORG” website.
11. Save and close the webpage in LU 5 of the Learner Files folder.
12. Open save_us.html in a web browser to see that webpage is coded correctly.
1. A website was created for a quiz for Computer Applications Technology. In Notepad++, open the
incomplete quiz.html webpage, in LU 5 of the Learner Files folder. Question numbers are inserted
as comments in the coding as guidelines to show approximately where the answer(s) should be
inserted.
2. Change the font of the heading “Computer Applications Technology Quiz” to Forte AND the font size
to 10 pt.
3. Change the top row of the table which contains the text “Quiz for Computer Applications Technology”
as follows:
3.1. Merge the cells over the four columns.
3.2. Vertically align the data to the top of the cell.
4. Change the shading of the column headings in the second row to white.
5. Change the bullets of the answers to the first question, “1. Which ONE of the following…”, to
numbering in the format A, B and C.
6. The tag <input type="text"> is used to provide a space to enter data. A space to enter
answers is provided for every question, except the first question. Enter the tags to provide a space
to enter the answer to the first question.
ClientID cannot be a primary key as 86 and 85 are duplicated in the table. The combination of ClientID
and CarName would be unique as there are no duplicates.
Whenever a primary key is chosen, assumptions are made. In this case it is assumed that no person has
the two cars of the same type. This is not a good assumption, since John Doe could collect cars and
specialise in collecting tanks. If John Doe bought another tank, this tank could not be added to the
database and John Doe could not be taught how to park his new tank.
A solution could be to add a numeric ID field for the cars.
A suitable primary key for this table could be the combination of ClientID and CarID.
The table could be written as the relation:
ParkCars (ClientID, First Name, Surname, Email, CarID, CarName, CarRate)
Example 2
The simplified details of a company's employees are stored in a table. Employees are allocated to
different departments, but some employees work in more than one department (Shuraya works in both
marketing and sales). Each department is in a different room and the room number of the department is
stored in the table called EmployeeDepts.
A combination of fields needs to be chosen that will uniquely identify a row (record) in the table. In this
case, Employee and Room No will create a unique primary key.
By choosing this key, it is assumed that no two people have the same surname and that only one
department can be in a room. What if there were people with the same surname and what if two
departments shared a room?
An EmployeeID field could be added to uniquely identify employees combined with the Department
name to create a concatenated key. This is assuming that departments do not change their names.
EXERCISE 1
2.1. Is it possible that a person can buy the same items on a different day?
2.2. If the store stocked red and blue T Shirts, would the table need to be changed?
2.3. Choose a concatenated primary key for this table.
2.4. What assumptions are made by choosing this key?
3. A medical centre records appointments made by patients with the resident dentists in a table called
Appointments. Each dentist has a unique DentistID and each patient has a unique PatientID.
One dentist can have appointments with many patients, and a patient can see more than one
dentist. The medical centre has 3 rooms for dental procedures.
3.1. Is it possible for a dentist to see the same patient on a different day?
3.2. Why is the combination of DentistID and PatientID not a suitable primary key?
3.3. What field can be added to DentistID and PatientID to create a primary key?
3.4. What assumptions are made by choosing this primary key?
Study the table called StudentMarks which stores a student's name, address, register class, theory and
practical mark for CAT and their overall CAT result which is the average of the theory and practical
marks.
• Update
• Insertion
• Deletion
4. Complex queries
Extracting "Hockey" may not seem to complex, but what if Patience decides to take up Cricket instead
of Hockey?
The Sport field is also problematic since it is non-atomic. The solution for non-atomic fields is to split the
filed into separate fields.
Simply put, a repeating group is a field that can have multiple values. When repeating groups are
removed, data redundancy is produced. In a normalised database, all fields should have a single value.
The data in a cell cannot store multiple values.
• A repeating group occurs when a field contains more than one value.
• Repeating groups produce invalid tables since it infringes on the primary key.
• Inserting multiple values in a cell is not possible
• Expanding the primary key produces data redundancy.
8.7 Anomalies
The ParkCars table will be used to explain anomalies.
EXERCISE 3
1.1. Update
1.2. Delete
1.3. Insert
2. Study the table called RecipeIngredients that stores the ingredients for recipes.
RecipeID Name Ingredients
1 Chocolate Cake Flour, eggs, butter, milk, baking powder, cocoa
2 Chocolate Brownies Flour, eggs, cocoa, margarine
3 Sponge Cake Flour, eggs, butter, milk, baking powder,
4 Crunchies Flour, oats, desiccated coconut, butter, baking soda, water
5 Pancakes Flour, eggs, milk
CHECK POINT 1
8.9 Relationships
In all the previous tables, the data should be stored in more than one table. A single table can be
separated into different subjects or categories which will be called entities. For example, the
Appointments table stores details about Dentists, Patients and Appointments. These tables need to
be linked using primary and foreign keys.
To work out how to create these links, the relationship between the subjects needs to be identified.
There are three types of relationships: one-to-one (1 : 1), one-to-many (1 : n) and many-to-many (m :
n).
8.9.1 One-to-One (1 : 1)
For example, in the Student table, each student is allocated to a register (home room) class (12A, 12B
or 12C). Each register class has one teacher in charge of the administration of that class. For example,
Ms Kubeka is the register teacher for class 12A. The relationship between the register class (as a whole)
and the teacher is one-to-one. A one-to-one relationship does not present a problem in databases as
there is no repeating data. A one-to-one relationship is indicated graphically by two boxes joined by a
line and with 1's on either side.
1 1
Entity Entity
1 1
Teacher Register
Class
One-to-one relationships are simple to deal with. Both fields are put in the same table. The teacher's
name would be one field and so would the name of their register class be a field in the same table.
Entity
1
∞ Entity
House
1
∞ Student
8.9.3 Many-to-Many (m : n)
In a hospital, there are many doctors and many patients. One doctor may see many patients and one
patient may have many doctors. This is a many-to-many relationship. It is shown graphically using two
boxes for the entities and a line joining them. A m and n show the many-to-many relationship. In MS
Access, an ∞ is used in place of m an n.
Entity
∞ ∞ Entity
∞ ∞
Doctor Patient
EXERCISE 4
ACTIVITY 1
Give two other examples of many-to many relationships.
Car
1 ∞ Repairs
8.10.1.4 Link the Tables Using the Primary and Foreign keys
The rule is that the table on the many side gets the primary key of the table on the one side of the
relationship. The primary key that is added becomes the foreign key in the many table. In this set of
relations, the primary keys have a double underline, and the foreign key has a single underline.
So, the Repairs table must get the RegNo field of the Car table.
Car (RegNo, Make, Model)
Repairs (RepairID, Date, Description, Cost, RegNo)
The tables would appear as:
Car
123456 VW Beetle
EXERCISE 5
Using the above tables, linked by RegNo field answer the questions:
1. What repairs were made to the Mazda CX 5?
2. Which car had the windscreen replaced?
3. How many repairs did the Ford Fiesta have?
4. In this database design, could a car have two different repairs on the same day?
PlayList
1 ∞ Songs
There is a many-to-many relationship between the recipes and the ingredients. One recipe can have
many ingredients and one ingredient can be in many recipes.
Recipe
∞ ∞ Ingredient
Recipe 1 1 Ingredient
∞ RecipeIngredient ∞
8.10.3.4 Link the Tables Using the Primary and Foreign Keys
Recipe RecipeIngredient
RecipeID RecipeName RecipeID IngredientID
1 Chocolate Cake 1 1
2 Chocolate Brownies 1 2
3 Sponge Cake 1 3
4 Crunchies 1 4
5 Pancakes 1 5
1 6
Ingredient 2 1
IngredientID IngredientName 2 2
1 Flour 2 6
2 Eggs 2 7
3 Butter 3 1
4 Milk 3 2
5 Baking Powder 3 3
6 Cocoa 3 4
7 Margarine 3 5
8 Desiccated Coconut 4 1
9 Baking Soda 4 11
10 Water 4 8
11 Oats 4 3
4 9
4 10
5 1
5 2
5 4
The link table RecipeIngredient has multiple records for each recipe. Chocolate cake (RecipeID 1) has
6 ingredients, hence there are 6 records in the RecipeIngredient table for chocolate cake. Milk
(IngredientID 4) is used in chocolate cake (RecipeID 1), sponge cake (RecipeID 3) and pancakes
(RecipeID 5). There are 3 records in the RecipeIngredient table for each recipe that has milk as an
ingredient.
The combined keys of RecipeID and IngredientID form a unique key in the RecipeIngredient table.
Each recipe is linked to all its ingredients and vice versa.
PlayList
∞ ∞ Songs
To solve this problem, introduce a new table and copy the primary keys from each of the tables into the
third table. Remove the PlayListID field from the Songs table since the relationship is no longer one-to-
many. Create a third table called PlayListSongs with the primary keys of both tables.
PlayList (PlayListID, PlayListName, Type)
Songs (SongID, SongTitle, ArtistName)
PlayListSongs (PlayListID, SongID)
The primary key of the PlayListSongs table will be a concatenation of PlayListID and SongID.
In the Appointments table, there are three entities, Dentists, Patients and Appointments.
The relationships between the entities are:
• Dentist to Patients is many-to-many. (One Dentist has many Patients and one Patients can have
many Dentists)
Page 50 Learning Unit 8 Database Normalisation
• Dentist to Appointments is one-to-many. (One Dentist can have many Appointments)
• Patient to Appointments in one-to-many. (One Patient can have many Appointments)
The three tables can be created:
Dentist (DentistID, Dentist First Name, Dentist Surname)
Patient (PatientID, Patient First Name, Patient Surname)
Appointment (AppointmentDateTime, Room No)
An extra table needs to be created for the many-to-many relationship between Dentist and Patients with
a combination of both primary keys.
DentistPatient (DentistID, PatientID)
For the one-to-many Dentist to Appointments relationship, the Appointment table gets the primary key
(DentistID) of the Dentist table. Similarly, the Appointments table gets the primary key (PatientID) of the
Patient table.
The relations become:
Dentist (DentistID, Dentist First Name, Dentist Surname)
Patient (PatientID, Patient First Name, Patient Surname)
Appointment (AppointmentDateTime, Room No, DentistID, PatientID)
Dentist Patient
DentistID Dentist Dentist PatientID Patient Patient
First Surname First Name Surname
Name
D101 Shirley Nel P100 Ronel Peter
D102 Thabo Muller P101 Tracey Davids
D103 Desiree Mohammed P102 Darren Greef
D104 Alicia Ndlovu P104 Lebogang Jacobs
P105 Neo Ally
Appointment
ApointmentDateTime Room No DentistID PatientID
17/08/2020 10:00 1 D101 P100
17/08/2020 10:00 2 D102 P101
17/08/2020 11:00 1 D103 P102
18/08/2020 9:00 3 D104 P102
18/08/2020 9:00 2 D102 P100
18/08/2020 9:00 1 D103 P104
19/08/2020 14:00 1 D104 P101
20/08/2020 15:00 2 D104 P105
20/08/2020 9:00 2 D102 P101
EXERCISE 7
EXERCISE 8
1. An electronic store sells monitors, speakers and cell phones. These products are supplied by
manufacturers. Each product has a price and a description. Note that one manufacturer can supply
many products and one product can be supplied by different manufacturers. An example of the
data is stored in the table below:
Manufacturer Address ProductName Description Price
15 Sunset BD, Los
ACME Monitor High resolution 23 inch R5 999.00
Angeles
15 Sunset BD, Los
ACME Cell phone 3 cameras, biometrics scanner R10 000.00
Angeles
Blue tooth
SpeakCo 18, HW Street Can pair with multiple devices R2 250.00
speaker
SpeakCo 18, HW Street Monitor High resolution HDMI R2 250.00
Runner
∞ School
1
1
∞
Result
∞ 1
Race
8.11.4 Link the Tables Using the Primary and Foreign Keys
Place the primary keys of the table in the one side of the relationships as foreign keys in the tables on
the many side of the relationships. The tables become:
tblRunner (RunnerID, Name, DOB, SchoolID)
tblSchool (SchoolID, Name, Captain, Rate)
tblResult (ResultID, RunnerID, RaceID, Time)
tblRace (RaceID, Name, Dist, Date)
Note that tblResult has 2 foreign keys.
tblResult
RunnerID RaceID Time
1 1 1:16:52
5 1 1:18:24
17 1 1:20:32
19 1 1:23:16
20 1 1:25:03
…
18 1 2:15:53
16 1 2:16:10
8 1 2:22:48
2 1 2:23:51
4 1 2:32:51
…
9 2 2:31:18
16 2 2:30:20
3 3 2:01:22
6 3 2:11:41
1 4 2:28:28
…
3 4 4:06:07
19 5 2:32:45
7 5 2:50:12
15 5 3:09:52
6 5 3:55:09
There is still some data redundancy in the database. The captains of the schools have their names
stored twice: in tblRunner and in tblSchool. Replace these names with their RunnerID's in tblSchool
to solve this problem:
tblSchool
SchoolID Name Captain Rate
1 Bolts 14 5
2 Jets 12 5.5
3 Miles 13 6
4 Underdogs 10 6.5
tblRace tblSchool
RaceID Name Dist Date SchoolID Name Captain Rate
1 Wonderpark 21 2019/01/12 1 Bolts 14 5
2 Rainbow 21 2019/03/16 2 Jets 12 5.5
3 Combat Run 21 2019/05/01 3 Miles 13 6
4 Combat Run 42 2019/05/01 4 Underdogs 10 6.5
5 Irene 42 2019/05/25
Rewrite the RunningClub database as a set of relations, correcting the above errors.
Learning Unit 8 Database Normalisation Page 57
8.12 Referential Integrity
Once database has been designed to be reliable and extendable, with tables linked by primary and
foreign keys, the designer needs to ensure queries cannot be performed that will violate the integrity of
the database. These queries could be deleting a race in the RunningClub database when runners still
have results listed in that race. Before referential integrity can be enforced, a primary key must be
defined in each table in the RunningClub database.
ACTIVITY 2
Load MS Access and open the database RunningClub found on the website at
http://www.funworks.co.za/FileDownloads/CATFiles.aspx.
Open tblRunner in Design view. Set the field RunnerID as a primary key by selecting the
RunnerID field and clicking the Primary Key button.
Do the same to set RaceID as the primary key in tblRace and SchoolID as the primary key in
tblSchool.
The table tblResult has a composite key, so in Design View of tblResult, select BOTH RunnerID
and RaceID and then click the Primary Key button. Both fields should show a key next to them.
Check that this representation in Access has the same relationships as the RunningClub database
designed earlier in this Learning Unit.
Runner
∞ School
1
1
∞
∞ 1
Result Race
• No repeating groups
• Choose a primary key
2NF
• Relation is in 1NF
• No partial dependencies
3NF
• Relation is in 2NF
• No transitive dependencies
Before we can begin to normalise a table, we need to look at the concept of one field being dependent
on another and the relationships between data in the database.
8.13.2 Dependencies
Simply put, a dependency is where one field is related to another. This can be represented by A ➔ B
which means B is determined by A.
A simple example is a car's make and model. The model of the car determines the make. For example, a
Volkswagen Polo is made by Volkswagen and the model is Polo. So, if you know the model of the car
(Polo) then there can be only one make (Volkswagen). Note that you cannot say this the other way
around. A make does not determine a model. Volkswagen make many different models of cars and
knowing the make of the car does not give us the model.
In the ParkCars table the ClientID determines the First Name, Surname and Email. The CarID
determines the Make, Model and CarRate. The CarRate is not dependent on the client's name or
ClientID, it is an indication of how difficult it is to park the car. It has nothing to do with the client (a client
may not be able to parallel park but that would relate to all cars).
In the above table, Name depends on the StuID and not Sport. If you have a student's ID then you
could work out their name. In the same way, Coach depends on the Sport.
Can you spot any more partial dependencies in the Student relation?
CHECK POINT 2
Sports Players
3NF – Completed
We can now write the relations as follows:
Students (StuID, Name, Grade, House)
Sports (Sport, Coach, Practice Day)
Players (StuID, Sport, NumMatches)
Houses (House, House_Colour)
At this stage, it is important that we define what a foreign key is. A foreign key is a field in a table that is
a primary key in another table. In the Students table, House is a foreign key as it is a primary key in the
Houses table. The foreign keys link tables together if they are not linked via the primary keys.
It is all very well to have 4 tables that are nicely broken up, but can you link them together? See if you
can answer these questions by looking at the tables.
ACTIVITY 4
What sport does Hennie Visser play?
How many matches has Joe Soap played?
When is the Rugby first teams' practice day?
What colour is Roger Philips' house?
Who is coached by Jones?
Who is in Cambridge house?
EXERCISE 9
1. Software Company
Adapted from Database Normalisation Exercise - Dominic Gruijters 2008 Used with Permission
To understand the data which has been given to you, an outline of the real-world scenario for the
Software Company is laid out below:
2.1. Consider the following table storing the results of first year Computer Science students. Each
student has a Matric_no field (since students register in their matric year) which uniquely
identifies the student. Some of the students have taken more than one subject during their
first year.