The document outlines topics to be examined for a database systems exam, including the relational model, relational design concepts like normalization, SQL programming, entity-relationship modeling, and sample exam preparation materials. Key topics are the relational model, normalization to BCNF and 3NF, SQL queries and operators, constructing ER diagrams and mapping to relational schemas. Sample exam questions and past papers are provided to help prepare.
2. Revision 2
Topics to examine: Relational
model and relational design
• Relational model and relational design
– Schema, database instance, relation
instance, attribute, domain, primary key,
foreign key, data redundancy and
anomalies,
– BCNF, 3NF, decomposition algorithms,
lossless join and dependency preserving
3. Revision 3
Topics to examing – SQL
programming
• Write SQL queries
– Simple queries
– Join queries
– Subqueries
• IN, NOT IN, EXISTS, NOT EXISTS
– Set operators
– Aggregate functions: count(), max, min, avg(),
sum()
• Explain SQL queries in English
• Find and correct syntax errors in SQL queries
4. Revision 4
Topics to examine: (standard) ER
modelling
• Understand symbols in an ER diagram
– Entities, relationships, multiplicity, weak
entities
• Map an ER model into a relational
database model
• Construct an ER model from given
description
5. Revision 5
Topics not to examine
• Advanced topics and post-relational
databases
– EER, O-O, “real” SQL programming, Data
mining, data warehousing
6. Revision 6
Relational model and design: BCNF
(Lecture RM2)
To decide if a relation is in BCNF,
– Given applicable FDs, compute the
minimal basis
– find all candidate keys for the relation
– Check if all minimal FDs meet the definition
of BCNF – the l.h.s is a (candidate) key.
– A relation that does not have any
applicable FDs … BCNF!
7. Relational model and design: 3NF
(Lecture RM3)
• To check if a relation is in 3NF:
– Given applicable FDs, compute the
minimal basis
– find all candidate keys for the relation
– Check if all minimal FDs meet the definition
of 3NF – the l.h.s is a key, or otherwise the
r.h.s is part of a (possibly different) key
Revision 7
8. Revision 8
Relational model and design …
Consider relations and FDs:
Supplier(suppName, suppAddr, suppPhoneNo)
OrdSupp(orderNo, suppName, managerName, quote)
suppName suppAddr, suppPhoneNo
suppPhoneNo suppAddr
orderNo, suppName managerName, quote
orderNo managerName
Explain if relations are in BCNF or 3NF. If not in
BCNF or 3NF, decompose into relations in
BCNF/3NF.
9. Revision 9
Supplier and OrdSupp are not in BCNF or
3NF
Supplier(suppName, suppAddr, suppPhoneNo)
OrdSupp(orderNo, suppName, managerName, quote)
minimal basis:
FD1: suppName suppPhoneNo
FD2: suppPhoneNo suppAddr
FD3: orderNo, suppName quote
FD4: orderNo managerName
Supplier:
candidate keys for Supplier: {suppName} –workout on next slide.
FD2 violates BCNF – e.g. the l.h.s is not a key.
FD2 also violates 3NF – the r.h.s. is not part of a key.
So Supplier is not in BCNF or 3NF.
OrdSupp:
candiate keys: {orderNo,suppName} –workout on next slide.
FD4 violates BCNF as well as 3NF. So OrdSupp is not in BCNF or
3NF.
10. Finding candidate keys
For each relation, use applicable minimal FDs,
working out candidate keys from l.h.s of FDs.
For FD1 and FD2 applicable for the relation
Supplier:
{suppName}+={suppName, suppPhoneNo, suppAddr}
{suppPhoneNo}+={suppPhoneNo, suppAddr}
For FD3, FD4 applicable on the relation OrdSupp:
{orderNo, suppName}+={orderNo, suppName, quote, managerName}
{orderNo}+={orderNo, managerName}
Revision 10
11. Revision 11
What is wrong with Supplier?
Populate the schema with sample data
– Data redundancy! The fact that 99012245 is at the address “3 Farmer St,
Melb” is repeated many times and similarly that 93452695 is at the address
“4 Blooo St, Prhan” is repeated many times.
12. Revision 12
What is wrong with OrdSupp?
• Data redundancy, as is demonstrated by
sample data.
13. Revision 13
Relational model and design …
(Lecture RM3)
• Decomposition algorithm in RM3.
– Find all candidate keys for the given relation.
– Construct a minimum basis for FDs.
– One relation for each FD in the minimal
basis.
– If no key of the original relation is
contained in any resultant relation, add one
relation whose schema is a key.
19. Revision 19
SQL Programming: syntax
select prod group, sum(list price*qty on hand) as_ _ _ _
total value_
from Products
where description like ‘%T%’ or description like ‘%t%’
group by prod group_
having sum(list price*qty on hand) =2000_ _ _ >
order by prod group;_
21. Revision 21
SQL programming: Logic
select distinct prod cod_
from products
where prod group!='C');_
select prod cod_
from products
minus
select prod cod_
from products
where prod group='C'_
C
prod_cod prod_group
C
prod_cod prod_group
Queries are the same!
22. Revision 22
SQL Programming: Logic
select prod group_
from products
where prod cod not like '%K_
%’;
select prod group_
from products
minus
select prod group_
from products
where prod cod like '%K_
%’;
K
S
prod_cod prod_group
K
S
prod_cod prod_group
Queries are different!
23. Revision 23
ER modelling
• Construct an ER model from given
description
• Map an ER model into a relational
database schema
24. Revision 24
Construct an ER Diagram
A worksite at a particular address has several
named workers with tax file numbers and
tasks. Building materials of certain type and
quantities are delivered by named trucking
companies on a date to a supervisor at the
worksite; there are several manufacturers of
each kind of material, each with their own
business name and address. (Tute sheet
ER2-Question 3)
26. Revision 26
Map an ER diagram into a
relational database schema
Manufacturer(name, address)
TruckCom(name, addr)
Worker(TFN, name, task, worksiteAddr*)
Material(Type)
MadeBy(materialType*, manufName*)
WorksiteSupervise(addr, workerTFN*)
Delivery(truckcomName*, materialType*,
workerTFN*, delDate, qty
27. Revision 27
Preparing for the exam
• Exam:
16 June 2015, 9:15am, 2hr 15 mins
• Exam cover sheet
• Exam header sheet
• Refer to BlackboardWeekly
Lectures/Tutes Week 12 / Preparing
for exam
– Sample exam paper
– Past exam paper
28. Consultation before the exam
• Consultation sessions with Jenny
(14.09.05). No appointments needed.
– 9 June, 4.00—6.00pm.
Revision 28
Editor's Notes
Syntax: the order of components for an SQL query.
Syntax: IN versus EXISTS.
Checking condition in on the “one” side, to find the “many” side in the query.
Query 1: every (prod_cod, prod_group) pair that do not satisfy the condition “prod_gorup = C” is removed.
Query 2: every (prod_cod, prod_group) pair that do not satisfy the condition “prod_gorup=C” is removed.
Query 1: condition is on the “many” side, query is finding the “one” side. Any (prod_cod, prod_group) pair that does not satisfy the condition “prod_cod like ‘%K%’ ” is excluded, but another pair with a different code but the same prod_group will be included.
Query 2: condition is on the “one” side, query is finding the “one” side. All (prod_cod, prod_group) pairs that do not satisfy the condition “prod_cod like ‘%K’ “, their prod_group is excluded.