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

Faculty of Science

Department of Computing Sciences

WRDV301 Database Systems


Assignment Guide
February 2020

Please read this document carefully and keep it in a safe place — it contains important information
that you will need to refer to during the year.
Possession of this document does not guarantee your registration (or acceptance) for this module, nor
does it guarantee access to the departmental computer laboratories.

© Department of Computing Sciences


Summerstrand South Campus
041-5042530
Contents
Contents ..................................................................................................................................... ii
Preparation................................................................................................................................. 1
[1] Database overview and data models.................................................................................... 2
[2] Modelling .............................................................................................................................. 4
[3] Normalisation........................................................................................................................ 6
[4] Beginning SQL ....................................................................................................................... 7
[5] Managing transactions and concurrency ............................................................................. 9
[6] Database performance tuning and SQL optimisation ........................................................ 11
[7] Distributed Databases ......................................................................................................... 12

Page ii
WRDV301 Assignment Guide 2020

Preparation
What you put into this module will most likely reflect what you get out of it. The quality of the assignments
submitted will, to a large extent, determine the quality of session discussions.
Assignments are to be submitted
 on time,
 in the correct place and
 in the correct format.

Where?
The Moodle page contains a section for weekly assignments. All preparation should be submitted into the
correct folder and in the appropriate format, as specified on the individual assignment sheets within the
weekly assignment section.

Format
Assignments will typically require typed up documents (using MS Word format) or diagrams (using MS Visio
2013). In cases of typed up documents or diagrams, you need to adhere to the following:
 Put your name, assignment number and due date of submission in the header of the document
 Add page numbers to the bottom of the page
 Use Calibri font size 11 as body text
 Filename should be your surname and initial, together with a version number, e.g.:
 BarnardLv1.docx (and possibly a later submission named BarnardLv2.docx)
 BarnardvdPostv1.docx (for group submissions; e.g. BarnardvdPostv2.docx for later submissions)
[As registered students at the university, you have access to Office365 (see the student portal for
information). Speak to Mr Jean Rademakers if you need Microsoft Access and Microsoft Visio.]

Page | 1
WRDV301 Assignment Guide 2020

[1] Database overview and data models


Due: Tuesday, 11 February 2020 @ 12:00 Type: Individual / group of 2

Objectives & Exit Level Outcomes


Design relational models and create relational schemas 1

Reference material
Chapter 2

Tasks [25]
1. Consider the following tables and then use the sample data (only an extract from the 16
database, not the full data set) and the table structures to answer the questions that
follow.

 A HOLDER is a person that has taken out some form of insurance by means of a
specific policy.
 A POLICY is a type of insurance, for example life insurance, funeral cover, disability
cover; typically offered by a specific company.
 A DEPENDANT is someone that is related to a HOLDER, for example a child of a
HOLDER.

Page | 2
WRDV301 Assignment Guide 2020

a) Explain the relationships that exist between HOLDER, DEPENDANT and POLICY, and also (8)
discuss the business rules that would govern the relationships between HOLDER,
DEPENDANT and POLICY.

b) Use the business rules you have identified in (a) to create UML class diagram. (Only give (4)
the entities and the associated relationships – no need to add attributes.)

c) Create an ER model using Crow’ Foot notation. (4)

2. Use at least two sources for each (NOT the prescribed text), properly cited and 9
referenced using the APA referencing technique1, to answer the following:
a) Explain the concept “Big Data” and give ONE example of where it is actually used. (3)

b) Explain what a NoSQL database is and give ONE example of where it is actually used. (3)

c) Appropriate use of APA referencing. 1 (3)


Submit TurnitIn report generated at submission time.2

1
Go to the NMU Library page; select the Reference Styles link in the Useful Links information block. Take note
that this reference style includes page numbers.
2
The TurnitIn report, indicating no plagiarism, is a requirement for Question 2 to be marked.
Page | 3
WRDV301 Assignment Guide 2020

[2] Modelling
Due: Tuesday, 25 February 2020 @ 12:00 Type: Individual / group of 2

Objectives & Exit Level Outcomes


Design relational models and create relational schemas 1

Create conceptual, logical and physical data models for a given scenario; 2

Reference material
Chapters 4 & 5

Tasks [38]
1. Consider the following CONTRACTOR and LABOURER entities and the relationships 6
between them. Only use the entities and attributes provided, unless otherwise stated.
Answer the questions that follow.

CONTRACTOR
LABOURER
PK Contract_ID
PK FK Contract_ID

Contract_Name
PK Labour_ID

Contract_Owner_FName
Labour_FName
Contract_Owner_LName
Labour_LName
Contract_CellPhone
Labour_CellPhone
Contract_Email
Labour_Rate
Contract_Rate

sub-contracts to

a) Identify and explain the relationship degrees present in the given model. (4)

b) Is LABOURER a strong or weak entity? Motivate your answer. (2)

2. Instructions for this question: 32


1. The following diagram needs to be completed using MS Visio.
2. Select the SIMPLE theme in the DESIGN tab
3. Save your diagram using your student number as filename
4. Once you have completed your diagram,
a. ensure your diagram fits onto a single A4 page (you may change the
orientation - for this page only - to landscape, if required) and
b. use the Snipping Tool to copy your diagram into your MS Word document
Consider the following scenario and associated business rules.
A manufacturer produces a few high-cost, low volume products.
 Some of the products are assembled with multiple components.
Page | 4
WRDV301 Assignment Guide 2020

 For each product, the unique product code, the product description and the total
number of finished products available, should be recorded.
 Each component is used in the production of several products.
 Components may be purchased from any of the available vendors.
 For each component, a unique component code, component description and the
total number of components in stock should be recorded.
 Vendors may supply multiple components.
 For each vendor, the unique vendor code, the vendor contact person name, the
vendor email and the vendor contact phone number should be recorded.
 Each final product that is produced has a unique serial number (e.g. if 10 units of a
specific product code are manufactured, each of the 10 units will have a unique serial
number, but the products will share the same product code).
 Each individual component has a unique serial number (e.g. if 5 identical, but
separate, components are used in the production process, there will be one unique
component code, but there will be 5 unique component serial numbers).
 Since the products are high-cost products, it is important to keep accurate records
to ensure that the components of each individual product can be traced back to the
component supplier.

Create a complete ERD in Crow’s Foot notation that can be implemented in the relational
model for this manufacturer. Ensure that the ERD contains all attributes as indicated and
identify all primary and foreign keys.

Page | 5
WRDV301 Assignment Guide 2020

[3] Normalisation
Due: Tuesday, 03 March 2020 @ 12:00 Type: Individual / group of 2

Objectives & Exit Level Outcomes


Design relational models and create relational schemas; 1

Create conceptual, logical and physical data models for a given scenario; 2

Reference material
Chapter 6

Tasks [18]
1. The asset section of NMU maintains a set of ITEM records to keep track of all official NMU 18
items. All these items are bar-coded and the bar-codes are used to identify the items. An
item can only be in a single room, but often a single room houses multiple items. Each
building has a number (e.g. 09) as well as a building name (e.g. Embizweni). A building can
have multiple rooms. Each building has a building manager who would also be in charge of
all the assets within the building. A building manager can uniquely be identified by an
employee number. A sample of ITEM records are given below. The primary keys are shaded
in the table below.
ATTRIBUTE NAME SAMPLE VALUE SAMPLE VALUE SAMPLE VALUE
BARCODE 546589875 215487954 225458798
ITEM_DESC Kyocera FS2100 DN Minolta Bizhub C224e Asus Zenbook UX305
ROOM_NO 0240 0129 0015
BLD_NO 09 13 07
BLD_NAME Embizweni Chemistry Maths & Physics
MGR_NAME Thulani Mayekiso Stewart Hing Ramesh Subramoney
EMP_NUM 45120 32781 27813

a) Draw the dependency diagram for the table provided. Clearly identify any dependencies (6)
and indicate the dependency type.

b) In which normal form is the diagram in (a)? Motivate your answer. (2)

c) Identify all the functional dependencies (desirable as well as undesirable) as indicated by (5)
your dependency diagram.
You need to use the appropriate standard notation. For example, if A functionally
determines B, you will represent it as AB.

d) Decompose the dependency diagram in (a) into 3NF and give only the 3NF relational (5)
schemas. Do not add any additional attributes. Indicate the primary keys for each of the
identified relational schemas.

Page | 6
WRDV301 Assignment Guide 2020

[4] Beginning SQL


Due: Tuesday, 10 March 2020 @ 12:00 Type: Individual / group of 2

Objectives & Exit Level Outcomes


Write simple Structured Query Language (SQL) queries 3

Reference material
Chapter 7

Special instructions
1. Open the Lecturer database from the Moodle site.
2. Ensure your Access Options for Object Designers are set to SQL Server Compatible Syntax:
3. Use MS Access to complete the SQL queries as listed under Tasks.

SQL Server compatibility

4. Once you have completed the queries, copy the following to your Word document:
a. your SQL code (copy the code, do not snip or make a screen shot); and
b. a portion of your resultant table. Use the Snipping Tool – see Figure 1 - to snip only a portion of
the resultant table, which also shows the number of records in your resultant table – see example
in Figure 2. You may have to resize the output screen.

Figure 1 Snipping Tool

Number of records
Figure 2 Sample resultant table
5. Make sure that you have numbered your queries correctly in your MS Word submission document.

Page | 7
WRDV301 Assignment Guide 2020

Additional information
The relational schema for the LECTURER.accdb is as follows:
LECTURER(Lect_No, Lect_FName, Lect_LName, Lect_Office, Lect_Sub_LNo, Lect_DName, Lect_email)
DEPARTMENT(DName, HoDLno, Building)
STUDENT(Stu_No, Stu_FName, Stu_LName, Stu_SuperLNo)
COURSE(Code, Descr, Credit)
PREREQU(Code, PCode, MinMark)
TAKES(Stu_No, Code, Year, Mark)
TEACH(Lect_No, Code, Semester)

Tasks [20]
1. Write queries to display the following:
a) Write the SQL to display all course codes with a credit value that is higher than the credit (5)
value of all the courses lectured by Jean Greyling.

b) Write the SQL code to list the names of the heads of departments who supervise at least (4)
one student.

c) Write the SQL code to return a list of all the first and last names of each lecturer as well as (6)
the first and last names of each lecturer’s head of department.

d) Write the SQL code to return the student number, first name and last name of the students (5)
who obtained the best marks for WRDB301 or WRUI301. Display the course code and the
mark obtained (as HighestMark) after the student last name.

Page | 8
WRDV301 Assignment Guide 2020

[5] Managing transactions and concurrency


Due: Tuesday, 07 April 2020 @ 12:00 Type: Individual / group of 2

Objectives & Exit Level Outcomes


Discuss concurrency control techniques and principles; 6

Reference material
Chapter 10

Tasks [29]

1. Consider the following scenario. 18


You work in a pharmaceutical company that manufactures drugs (medicines). One such
drug is Panado-Co. One Panado-Co 500mg tablet contains several components, for
example paracetamol, codeine phosphate and potassium sorbate.
Each time a production run of tablets takes place on the production line, the number of
available (produced) Panado-Co 500mg tablets should be increased, and the stock
availability of the tablet components (paracetamol, codeine phosphate and potassium
sorbate ) should be decreased.
For the purpose of this question, assume that a single Panado-Co 500mg tablet will consist
of the following:
One Panado-Co 500mg tablet = 500mg paracetamol + 8mg codeine phosphate + 1 quantity
of potassium sorbate
The following tables are sample database tables of the pharmaceutical company,
indicating the products and components that are currently available (i.e. in stock):
PRODUCT table COMPONENT table
PROD_CODE PROD_QOH COMP_CODE COMP_QOH
Pan001 250 600 Par001 660 000 000
Co001 450 400
Pot001 75 300

Pan001 is the product code for Panado-Co 500mg tablets.


Par001 is the component code for paracetamol (quantity measured in milligram, thus 660
000 000 in the COMP_QOH means 660 000 000mg).
Co001 is the component code for codeine phosphate (quantity measured in milligram, thus
450 400 in the COMP_QOH means 450 400mg).
Pot001 is the component code for potassium sorbate.
a) You need to create the transaction (all the database requests in SQL) to update the (9)
PRODUCT and COMPONENT tables for a production run of 2500 Panado-Co 500mg tablets.
Your transaction should start with BEGIN TRANSACTION and should end off with COMMIT.

b) Create a transaction log of the transaction you have created in a). (9)

Page | 9
WRDV301 Assignment Guide 2020

Assume that the database is currently in a consistent state and assume that this
transaction is the only transaction currently executed by the DBMS. Use the sample table
provided on the next page as starting point for your transaction log.
TRL ID TRX NUM PREV NXT OPERATION TABLE ROW ID ATTRIBUTE BEFORE AFTER
PTR PTR VALUE VALUE

65 123 NULL 66 START *START TRANS*

66 123

2. Consider the following sequence of transaction operations, listed in the order in which it 11
is submitted to the database management system.
S1: T1:R(X), T2:R(Y), T3:W(Y), T2:W(Z), T3:R(X), T1:W(Z), T1 commits
The timestamps of the transactions are as follows:
T1: 54289
T2: 54290
T3: 54291
Make use of timestamping concurrency control, implemented using the Wait / Die
scheme. Use the template below to to show how the sequence is handled. Partial
information has already been provided.

T1:R(X) T1 requests a shared lock on X and….

T2:R(Y)

T3:W(Y)

T2:W(Z)

T3:R(X)

T1:W(Z)

T1 commits

Page | 10
WRDV301 Assignment Guide 2020

[6] Database performance tuning and SQL optimisation


Due: Tuesday, 14 April 2020 @ 12:00 Type: Individual / group of 2

Objectives & Exit Level Outcomes


Explain the difference between DBMS and SQL performance tuning and recommend techniques 8
for query optimization;

Reference material
Chapter 11

Tasks [22]
1. Explain the difference between SQL performance tuning and database performance 6
tuning.

2. In simple terms, the DBMS processes queries in three phases. Identify the phases and 6
explain what happens in each phase.

3. The following relational database schemas are defined to store event information: 10
Event (Event_Id <PK>, EventName, StartDate, EndDate, Venue_ID, SeatCost)
Artist (Artist_Id <PK>, ArtistName, TelNo)
Artist_Event (Artist_Id<PK><FK>, Event_Id <PK><FK>)
Booking (Booking_Id <PK>, Event_Id <FK>, Date, NumSeats, ContactNo)
Venue (Venue_ID, VenueName, SeatCapacity)

The following query is given:


SELECT EventName, StartDate, EndDate, ArtistName
FROM Event, Artist, Artist_Event
WHERE StartDate > ‘01/05/2018’ AND EventName = ‘Rocking the Daisies 2018’ AND
Event.EventId = Artist_Event.Event_Id AND Artist.Artist_ID=Artist_Event.Artist_Id
ORDER BY StartDate;
a) Rewrite the above query so that it is optimized - only give the changes you propose. Explain (6)
why the changed query will be an optimised query.

b) Would it be useful to create any index(es)? Motivate your answer. (4)

4. Submit TurnitIn report generated at submission time.3

3
The TurnitIn report, indicating no plagiarism, is a requirement for Questions 1 and 2 to be marked.
Page | 11
WRDV301 Assignment Guide 2020

[7] Distributed Databases


Due: Tuesday, 21 April 2020 @ 12:00 Type: Individual / group of 2

Objectives & Exit Level Outcomes


Demonstrate an understanding of database transaction processing theory and related 5
concepts;

Reference material
Chapter 12

Tasks [13]
Use Figure P12.1 on page 586 for this question. 13
Operations can be remote requests, remote transactions, distributed requests, distributed
transactions.
Identify the minimum types of operations the database should support to perform the
operations listed below. Motivate your answer.
1. At site A: (2)
SELECT *
FROM INVOICE
WHERE INV_TOTAL>5000;

2. At site A: (2)
SELECT *
FROM PRODUCT
WHERE PROD_QOH<20;

3. At site B: (2)
SELECT *
FROM CUSTOMER;
(2)
4. At site B:
SELECT CUS_NAME, INV_TOTAL
FROM CUSTOMER INNER JOIN INVOICE ON CUSTOMER.CUS_NUM = INVOICE.CUS_NUM
WHERE INV_TOTAL>2000;

5. At site C: (3)
BEGIN WORK
INSERT INTO CUSTOMER(CUS_NUM,CUS_NAME, CUS_ADDRESS, CUS_BAL)
VALUES(‘2541’, ‘Sue Skinner’, ‘325 Hugh Rd.’,’0.00’);
INSERT INTO INVOICE(INV_NUM, CUS_NUM, INV_DATE, INV_TOTAL)
VALUES(‘58874’, ‘2541’, ’25 March 2013’, ’25.00’);
COMMIT WORK;

6. Would the operation at site C (see question 5 above) benefit from the use of a two-phase (2)
commit protocol? Motivate your answer.

Page | 12

You might also like