SlideShare a Scribd company logo
1 of 28
Revision 1
Revision
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
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
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
Revision 5
Topics not to examine
• Advanced topics and post-relational
databases
– EER, O-O, “real” SQL programming, Data
mining, data warehousing
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!
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
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.
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.
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
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.
Revision 12
What is wrong with OrdSupp?
• Data redundancy, as is demonstrated by
sample data.
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.
Revision 14
Decomposition of Supplier
• The Supplier Schema with applicable FDs:
Supplier(suppName, suppAddr, suppPhoneNo)
FD1: suppName  suppAddr, suppPhoneNo
FD2: suppPhoneNo  suppAddr
Key: {suppName}
• Minimal basis for FDs:
suppName  suppAddr (redundant)
suppName  suppPhoneNo
suppPhoneNo  suppAddr
• Resulting relations:
Phone-Addr(suppPhoneNo, suppAddr)
Supplier-Phone(suppName, suppPhoneNo*)
Revision 15
Decomposition of OrdSupp
• OrdSupp with applicable FDs:
OrdSupp(orderNo, suppName, managerName, quote)
FD3: orderNo, suppName  managerName, quote
FD4: orderNo  managerName
Key: {orderNo, suppName}
• Minimal basis for FDs:
orderNo, suppName managerName (redundant)
orderNo, suppName  quote
orderNo  managerName
• Resulting relations:
Order-Manager(orderNo, managerName)
Order-Quote(orderNo*, suppName, quote)
Revision 16
Why are the BCNF relations better?
The data redundancy in Supplier is removed!
Revision 17
Why are the BCNF relations better?
The data redundancy in OrdSupp is removed!
Revision 18
SQL Programming
The Rocky Concrete database:
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;_
Revision 20
SQL Programming: operators
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!
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!
Revision 23
ER modelling
• Construct an ER model from given
description
• Map an ER model into a relational
database schema
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)
Revision 25
Construct an ER Diagram ...
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
Revision 27
Preparing for the exam
• Exam:
16 June 2015, 9:15am, 2hr 15 mins
• Exam cover sheet
• Exam header sheet
• Refer to BlackboardWeekly
Lectures/Tutes  Week 12 / Preparing
for exam
– Sample exam paper
– Past exam paper
Consultation before the exam
• Consultation sessions with Jenny
(14.09.05). No appointments needed.
– 9 June, 4.00—6.00pm.
Revision 28

More Related Content

What's hot

What's hot (20)

Lecture11 abap on line
Lecture11 abap on lineLecture11 abap on line
Lecture11 abap on line
 
Database - Normalization
Database - NormalizationDatabase - Normalization
Database - Normalization
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
 
Functions-Computer programming
Functions-Computer programmingFunctions-Computer programming
Functions-Computer programming
 
Computer programming(CP)
Computer programming(CP)Computer programming(CP)
Computer programming(CP)
 
Normalization in databases
Normalization in databasesNormalization in databases
Normalization in databases
 
Pointers-Computer programming
Pointers-Computer programmingPointers-Computer programming
Pointers-Computer programming
 
Mainframe refresher-part-1
Mainframe refresher-part-1Mainframe refresher-part-1
Mainframe refresher-part-1
 
Normalization of Data Base
Normalization of Data BaseNormalization of Data Base
Normalization of Data Base
 
Normlaization
NormlaizationNormlaization
Normlaization
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
Structure
StructureStructure
Structure
 
6. Integrity and Security in DBMS
6. Integrity and Security in DBMS6. Integrity and Security in DBMS
6. Integrity and Security in DBMS
 
SAP Modularization techniques
SAP Modularization techniquesSAP Modularization techniques
SAP Modularization techniques
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
 
Functional dependencies and normalization
Functional dependencies and normalizationFunctional dependencies and normalization
Functional dependencies and normalization
 
Normalization
NormalizationNormalization
Normalization
 
Strings-Computer programming
Strings-Computer programmingStrings-Computer programming
Strings-Computer programming
 
Fundamentals of Programming Chapter 4
Fundamentals of Programming Chapter 4Fundamentals of Programming Chapter 4
Fundamentals of Programming Chapter 4
 
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NFNormalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
 

Similar to Revision1510(1)

Design dbms
Design dbmsDesign dbms
Design dbmsIIITA
 
Relational Database Design
Relational Database DesignRelational Database Design
Relational Database DesignPrabu U
 
Chuẩn hóa CSDL
Chuẩn hóa CSDLChuẩn hóa CSDL
Chuẩn hóa CSDLphananhvu
 
chap 10 dbms.pptx
chap 10 dbms.pptxchap 10 dbms.pptx
chap 10 dbms.pptxarjun431527
 
Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...
Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...
Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...Mydbops
 
Lecture No. 21-22.ppt
Lecture No. 21-22.pptLecture No. 21-22.ppt
Lecture No. 21-22.pptAjit Mali
 
MongoDB Tips and Tricks
MongoDB Tips and TricksMongoDB Tips and Tricks
MongoDB Tips and TricksM Malai
 
Netflix's Transition to High-Availability Storage (QCon SF 2010)
Netflix's Transition to High-Availability Storage (QCon SF 2010)Netflix's Transition to High-Availability Storage (QCon SF 2010)
Netflix's Transition to High-Availability Storage (QCon SF 2010)Sid Anand
 
Challenges of Building a First Class SQL-on-Hadoop Engine
Challenges of Building a First Class SQL-on-Hadoop EngineChallenges of Building a First Class SQL-on-Hadoop Engine
Challenges of Building a First Class SQL-on-Hadoop EngineNicolas Morales
 
MongoDB performance
MongoDB performanceMongoDB performance
MongoDB performanceMydbops
 
Oracle application tech stack tips and queries for troubleshooting advanced t...
Oracle application tech stack tips and queries for troubleshooting advanced t...Oracle application tech stack tips and queries for troubleshooting advanced t...
Oracle application tech stack tips and queries for troubleshooting advanced t...Muqthiyar Pasha
 
Bsc cs ii-dbms-u-iv-normalization
Bsc cs ii-dbms-u-iv-normalizationBsc cs ii-dbms-u-iv-normalization
Bsc cs ii-dbms-u-iv-normalizationRai University
 

Similar to Revision1510(1) (20)

Design dbms
Design dbmsDesign dbms
Design dbms
 
Normalization case
Normalization caseNormalization case
Normalization case
 
Relational Database Design
Relational Database DesignRelational Database Design
Relational Database Design
 
Chuẩn hóa CSDL
Chuẩn hóa CSDLChuẩn hóa CSDL
Chuẩn hóa CSDL
 
uniT 4 (1).pptx
uniT 4 (1).pptxuniT 4 (1).pptx
uniT 4 (1).pptx
 
chap 10 dbms.pptx
chap 10 dbms.pptxchap 10 dbms.pptx
chap 10 dbms.pptx
 
Unit 04 dbms
Unit 04 dbmsUnit 04 dbms
Unit 04 dbms
 
Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...
Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...
Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...
 
Rdbms
RdbmsRdbms
Rdbms
 
Lecture No. 21-22.ppt
Lecture No. 21-22.pptLecture No. 21-22.ppt
Lecture No. 21-22.ppt
 
L9 design2
L9 design2L9 design2
L9 design2
 
MongoDB Tips and Tricks
MongoDB Tips and TricksMongoDB Tips and Tricks
MongoDB Tips and Tricks
 
Netflix's Transition to High-Availability Storage (QCon SF 2010)
Netflix's Transition to High-Availability Storage (QCon SF 2010)Netflix's Transition to High-Availability Storage (QCon SF 2010)
Netflix's Transition to High-Availability Storage (QCon SF 2010)
 
Challenges of Building a First Class SQL-on-Hadoop Engine
Challenges of Building a First Class SQL-on-Hadoop EngineChallenges of Building a First Class SQL-on-Hadoop Engine
Challenges of Building a First Class SQL-on-Hadoop Engine
 
MongoDB performance
MongoDB performanceMongoDB performance
MongoDB performance
 
Database Presentation
Database PresentationDatabase Presentation
Database Presentation
 
Final exam in advance dbms
Final exam in advance dbmsFinal exam in advance dbms
Final exam in advance dbms
 
Oracle application tech stack tips and queries for troubleshooting advanced t...
Oracle application tech stack tips and queries for troubleshooting advanced t...Oracle application tech stack tips and queries for troubleshooting advanced t...
Oracle application tech stack tips and queries for troubleshooting advanced t...
 
Bsc cs ii-dbms-u-iv-normalization
Bsc cs ii-dbms-u-iv-normalizationBsc cs ii-dbms-u-iv-normalization
Bsc cs ii-dbms-u-iv-normalization
 
Normalisation revision
Normalisation revisionNormalisation revision
Normalisation revision
 

Recently uploaded

Call girls in Kanpur - 9761072362 with room service
Call girls in Kanpur - 9761072362 with room serviceCall girls in Kanpur - 9761072362 with room service
Call girls in Kanpur - 9761072362 with room servicediscovermytutordmt
 
FULL ENJOY - 9953040155 Call Girls in Burari | Delhi
FULL ENJOY - 9953040155 Call Girls in Burari | DelhiFULL ENJOY - 9953040155 Call Girls in Burari | Delhi
FULL ENJOY - 9953040155 Call Girls in Burari | DelhiMalviyaNagarCallGirl
 
Islamabad Call Girls # 03091665556 # Call Girls in Islamabad | Islamabad Escorts
Islamabad Call Girls # 03091665556 # Call Girls in Islamabad | Islamabad EscortsIslamabad Call Girls # 03091665556 # Call Girls in Islamabad | Islamabad Escorts
Islamabad Call Girls # 03091665556 # Call Girls in Islamabad | Islamabad Escortswdefrd
 
The First Date by Daniel Johnson (Inspired By True Events)
The First Date by Daniel Johnson (Inspired By True Events)The First Date by Daniel Johnson (Inspired By True Events)
The First Date by Daniel Johnson (Inspired By True Events)thephillipta
 
Turn Lock Take Key Storyboard Daniel Johnson
Turn Lock Take Key Storyboard Daniel JohnsonTurn Lock Take Key Storyboard Daniel Johnson
Turn Lock Take Key Storyboard Daniel Johnsonthephillipta
 
Deira Call Girls # 0522916705 # Call Girls In Deira Dubai || (UAE)
Deira Call Girls # 0522916705 #  Call Girls In Deira Dubai || (UAE)Deira Call Girls # 0522916705 #  Call Girls In Deira Dubai || (UAE)
Deira Call Girls # 0522916705 # Call Girls In Deira Dubai || (UAE)wdefrd
 
Charbagh / best call girls in Lucknow - Book 🥤 8923113531 🪗 Call Girls Availa...
Charbagh / best call girls in Lucknow - Book 🥤 8923113531 🪗 Call Girls Availa...Charbagh / best call girls in Lucknow - Book 🥤 8923113531 🪗 Call Girls Availa...
Charbagh / best call girls in Lucknow - Book 🥤 8923113531 🪗 Call Girls Availa...gurkirankumar98700
 
exhuma plot and synopsis from the exhuma movie.pptx
exhuma plot and synopsis from the exhuma movie.pptxexhuma plot and synopsis from the exhuma movie.pptx
exhuma plot and synopsis from the exhuma movie.pptxKurikulumPenilaian
 
Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...
Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...
Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...anilsa9823
 
Call Girl Service In Dubai #$# O56521286O #$# Dubai Call Girls
Call Girl Service In Dubai #$# O56521286O #$# Dubai Call GirlsCall Girl Service In Dubai #$# O56521286O #$# Dubai Call Girls
Call Girl Service In Dubai #$# O56521286O #$# Dubai Call Girlsparisharma5056
 
Bridge Fight Board by Daniel Johnson dtjohnsonart.com
Bridge Fight Board by Daniel Johnson dtjohnsonart.comBridge Fight Board by Daniel Johnson dtjohnsonart.com
Bridge Fight Board by Daniel Johnson dtjohnsonart.comthephillipta
 
Young⚡Call Girls in Uttam Nagar Delhi >༒9667401043 Escort Service
Young⚡Call Girls in Uttam Nagar Delhi >༒9667401043 Escort ServiceYoung⚡Call Girls in Uttam Nagar Delhi >༒9667401043 Escort Service
Young⚡Call Girls in Uttam Nagar Delhi >༒9667401043 Escort Servicesonnydelhi1992
 
FULL ENJOY - 9953040155 Call Girls in Shaheen Bagh | Delhi
FULL ENJOY - 9953040155 Call Girls in Shaheen Bagh | DelhiFULL ENJOY - 9953040155 Call Girls in Shaheen Bagh | Delhi
FULL ENJOY - 9953040155 Call Girls in Shaheen Bagh | DelhiMalviyaNagarCallGirl
 
Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...
Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...
Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...anilsa9823
 
Hazratganj / Call Girl in Lucknow - Phone 🫗 8923113531 ☛ Escorts Service at 6...
Hazratganj / Call Girl in Lucknow - Phone 🫗 8923113531 ☛ Escorts Service at 6...Hazratganj / Call Girl in Lucknow - Phone 🫗 8923113531 ☛ Escorts Service at 6...
Hazratganj / Call Girl in Lucknow - Phone 🫗 8923113531 ☛ Escorts Service at 6...akbard9823
 
Charbagh ! (Call Girls) in Lucknow Finest Escorts Service 🥗 8923113531 🏊 Avai...
Charbagh ! (Call Girls) in Lucknow Finest Escorts Service 🥗 8923113531 🏊 Avai...Charbagh ! (Call Girls) in Lucknow Finest Escorts Service 🥗 8923113531 🏊 Avai...
Charbagh ! (Call Girls) in Lucknow Finest Escorts Service 🥗 8923113531 🏊 Avai...gurkirankumar98700
 
Patrakarpuram ) Cheap Call Girls In Lucknow (Adult Only) 🧈 8923113531 𓀓 Esco...
Patrakarpuram ) Cheap Call Girls In Lucknow  (Adult Only) 🧈 8923113531 𓀓 Esco...Patrakarpuram ) Cheap Call Girls In Lucknow  (Adult Only) 🧈 8923113531 𓀓 Esco...
Patrakarpuram ) Cheap Call Girls In Lucknow (Adult Only) 🧈 8923113531 𓀓 Esco...akbard9823
 
Jeremy Casson - An Architectural and Historical Journey Around Europe
Jeremy Casson - An Architectural and Historical Journey Around EuropeJeremy Casson - An Architectural and Historical Journey Around Europe
Jeremy Casson - An Architectural and Historical Journey Around EuropeJeremy Casson
 
Aminabad @ Book Call Girls in Lucknow - 450+ Call Girl Cash Payment 🍵 8923113...
Aminabad @ Book Call Girls in Lucknow - 450+ Call Girl Cash Payment 🍵 8923113...Aminabad @ Book Call Girls in Lucknow - 450+ Call Girl Cash Payment 🍵 8923113...
Aminabad @ Book Call Girls in Lucknow - 450+ Call Girl Cash Payment 🍵 8923113...akbard9823
 

Recently uploaded (20)

Call girls in Kanpur - 9761072362 with room service
Call girls in Kanpur - 9761072362 with room serviceCall girls in Kanpur - 9761072362 with room service
Call girls in Kanpur - 9761072362 with room service
 
FULL ENJOY - 9953040155 Call Girls in Burari | Delhi
FULL ENJOY - 9953040155 Call Girls in Burari | DelhiFULL ENJOY - 9953040155 Call Girls in Burari | Delhi
FULL ENJOY - 9953040155 Call Girls in Burari | Delhi
 
Islamabad Call Girls # 03091665556 # Call Girls in Islamabad | Islamabad Escorts
Islamabad Call Girls # 03091665556 # Call Girls in Islamabad | Islamabad EscortsIslamabad Call Girls # 03091665556 # Call Girls in Islamabad | Islamabad Escorts
Islamabad Call Girls # 03091665556 # Call Girls in Islamabad | Islamabad Escorts
 
The First Date by Daniel Johnson (Inspired By True Events)
The First Date by Daniel Johnson (Inspired By True Events)The First Date by Daniel Johnson (Inspired By True Events)
The First Date by Daniel Johnson (Inspired By True Events)
 
Turn Lock Take Key Storyboard Daniel Johnson
Turn Lock Take Key Storyboard Daniel JohnsonTurn Lock Take Key Storyboard Daniel Johnson
Turn Lock Take Key Storyboard Daniel Johnson
 
Deira Call Girls # 0522916705 # Call Girls In Deira Dubai || (UAE)
Deira Call Girls # 0522916705 #  Call Girls In Deira Dubai || (UAE)Deira Call Girls # 0522916705 #  Call Girls In Deira Dubai || (UAE)
Deira Call Girls # 0522916705 # Call Girls In Deira Dubai || (UAE)
 
Charbagh / best call girls in Lucknow - Book 🥤 8923113531 🪗 Call Girls Availa...
Charbagh / best call girls in Lucknow - Book 🥤 8923113531 🪗 Call Girls Availa...Charbagh / best call girls in Lucknow - Book 🥤 8923113531 🪗 Call Girls Availa...
Charbagh / best call girls in Lucknow - Book 🥤 8923113531 🪗 Call Girls Availa...
 
exhuma plot and synopsis from the exhuma movie.pptx
exhuma plot and synopsis from the exhuma movie.pptxexhuma plot and synopsis from the exhuma movie.pptx
exhuma plot and synopsis from the exhuma movie.pptx
 
Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...
Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...
Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...
 
Call Girl Service In Dubai #$# O56521286O #$# Dubai Call Girls
Call Girl Service In Dubai #$# O56521286O #$# Dubai Call GirlsCall Girl Service In Dubai #$# O56521286O #$# Dubai Call Girls
Call Girl Service In Dubai #$# O56521286O #$# Dubai Call Girls
 
Bridge Fight Board by Daniel Johnson dtjohnsonart.com
Bridge Fight Board by Daniel Johnson dtjohnsonart.comBridge Fight Board by Daniel Johnson dtjohnsonart.com
Bridge Fight Board by Daniel Johnson dtjohnsonart.com
 
Young⚡Call Girls in Uttam Nagar Delhi >༒9667401043 Escort Service
Young⚡Call Girls in Uttam Nagar Delhi >༒9667401043 Escort ServiceYoung⚡Call Girls in Uttam Nagar Delhi >༒9667401043 Escort Service
Young⚡Call Girls in Uttam Nagar Delhi >༒9667401043 Escort Service
 
FULL ENJOY - 9953040155 Call Girls in Shaheen Bagh | Delhi
FULL ENJOY - 9953040155 Call Girls in Shaheen Bagh | DelhiFULL ENJOY - 9953040155 Call Girls in Shaheen Bagh | Delhi
FULL ENJOY - 9953040155 Call Girls in Shaheen Bagh | Delhi
 
Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...
Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...
Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...
 
Hazratganj / Call Girl in Lucknow - Phone 🫗 8923113531 ☛ Escorts Service at 6...
Hazratganj / Call Girl in Lucknow - Phone 🫗 8923113531 ☛ Escorts Service at 6...Hazratganj / Call Girl in Lucknow - Phone 🫗 8923113531 ☛ Escorts Service at 6...
Hazratganj / Call Girl in Lucknow - Phone 🫗 8923113531 ☛ Escorts Service at 6...
 
Charbagh ! (Call Girls) in Lucknow Finest Escorts Service 🥗 8923113531 🏊 Avai...
Charbagh ! (Call Girls) in Lucknow Finest Escorts Service 🥗 8923113531 🏊 Avai...Charbagh ! (Call Girls) in Lucknow Finest Escorts Service 🥗 8923113531 🏊 Avai...
Charbagh ! (Call Girls) in Lucknow Finest Escorts Service 🥗 8923113531 🏊 Avai...
 
Patrakarpuram ) Cheap Call Girls In Lucknow (Adult Only) 🧈 8923113531 𓀓 Esco...
Patrakarpuram ) Cheap Call Girls In Lucknow  (Adult Only) 🧈 8923113531 𓀓 Esco...Patrakarpuram ) Cheap Call Girls In Lucknow  (Adult Only) 🧈 8923113531 𓀓 Esco...
Patrakarpuram ) Cheap Call Girls In Lucknow (Adult Only) 🧈 8923113531 𓀓 Esco...
 
Indian Deira Call Girls # 0522916705 # Indian Call Girls In Deira Dubai || (UAE)
Indian Deira Call Girls # 0522916705 # Indian Call Girls In Deira Dubai || (UAE)Indian Deira Call Girls # 0522916705 # Indian Call Girls In Deira Dubai || (UAE)
Indian Deira Call Girls # 0522916705 # Indian Call Girls In Deira Dubai || (UAE)
 
Jeremy Casson - An Architectural and Historical Journey Around Europe
Jeremy Casson - An Architectural and Historical Journey Around EuropeJeremy Casson - An Architectural and Historical Journey Around Europe
Jeremy Casson - An Architectural and Historical Journey Around Europe
 
Aminabad @ Book Call Girls in Lucknow - 450+ Call Girl Cash Payment 🍵 8923113...
Aminabad @ Book Call Girls in Lucknow - 450+ Call Girl Cash Payment 🍵 8923113...Aminabad @ Book Call Girls in Lucknow - 450+ Call Girl Cash Payment 🍵 8923113...
Aminabad @ Book Call Girls in Lucknow - 450+ Call Girl Cash Payment 🍵 8923113...
 

Revision1510(1)

  • 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.
  • 14. Revision 14 Decomposition of Supplier • The Supplier Schema with applicable FDs: Supplier(suppName, suppAddr, suppPhoneNo) FD1: suppName  suppAddr, suppPhoneNo FD2: suppPhoneNo  suppAddr Key: {suppName} • Minimal basis for FDs: suppName  suppAddr (redundant) suppName  suppPhoneNo suppPhoneNo  suppAddr • Resulting relations: Phone-Addr(suppPhoneNo, suppAddr) Supplier-Phone(suppName, suppPhoneNo*)
  • 15. Revision 15 Decomposition of OrdSupp • OrdSupp with applicable FDs: OrdSupp(orderNo, suppName, managerName, quote) FD3: orderNo, suppName  managerName, quote FD4: orderNo  managerName Key: {orderNo, suppName} • Minimal basis for FDs: orderNo, suppName managerName (redundant) orderNo, suppName  quote orderNo  managerName • Resulting relations: Order-Manager(orderNo, managerName) Order-Quote(orderNo*, suppName, quote)
  • 16. Revision 16 Why are the BCNF relations better? The data redundancy in Supplier is removed!
  • 17. Revision 17 Why are the BCNF relations better? The data redundancy in OrdSupp is removed!
  • 18. Revision 18 SQL Programming The Rocky Concrete database:
  • 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)
  • 25. Revision 25 Construct an ER Diagram ...
  • 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 BlackboardWeekly 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

  1. Syntax: the order of components for an SQL query.
  2. Syntax: IN versus EXISTS.
  3. 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.
  4. 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.