ANN.1 CSE4701 Announcements - Spring 2015 March 2, 2015 HW 4 Due 11:59pm, Wednesday, March 4 Review Functional Dependencies/Normalization Semester Project Teams of 3 – 1 team of 4 Phase I – DB Design – Due March 13 11:59 Phase II – App D&D – Due April 20, 11:59 We’ll Discuss Today Upcoming Lectures March 4: Exam Review & XML – Steve March 12: DB Prog/php/REST API
47
Embed
ANN.1 CSE4701 Announcements - Spring 2015 March 2, 2015 HW 4 Due 11:59pm, Wednesday, March 4 Review Functional Dependencies/Normalization Semester.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
ANN.1
CSE4701
Announcements - Spring 2015March 2, 2015
HW 4 Due 11:59pm, Wednesday, March 4 Review Functional Dependencies/Normalization Semester Project
Teams of 3 – 1 team of 4 Phase I – DB Design – Due March 13 11:59 Phase II – App D&D – Due April 20, 11:59 We’ll Discuss Today
Upcoming Lectures March 4: Exam Review & XML – Steve March 12: DB Prog/php/REST API – Gino
Midterm Exam – Tuesday March 10, ITE138 Questions???
ANN.2
CSE4701
Problem 15.29 6th ed
Consider the table:Orders (O#,I#,Odate, Cust#, Total_amount, Qty_ordered, Total_price, Discount%)
What are the Functional Dependencies?:
Is it in 2 NF ?
O# Odate Cust# Total_amt
O# I# Qty_ordered Total_price Discount%
No! Odate, Cust#, Total_amt Partially Dependent on only Part of Key O# I# namely O#
ANN.3
CSE4701
Problem 15.29 6th ed
How do you Fix the Single Orders Table?
Is it in 3NF? Yes – No transitive functional
dependencies XY and Y Z , with X as the Primary Key, where Y is not a candidate key
Create Two Tables Order (O#,Odate, Cust#, Total_amount)OrderedItem (O#,I#, Qty_ordered, Total_price, Discount%)
ANN.4
CSE4701
Problem 15.30 6th ed
Consider the table:CAR_SALE( Car# , Date_sold, Salesman#, Commision%, Discount_amt)
Assumptions Car can be sold by Multiple Salepersons Thus, Primary Key: Car# , Salesman# w/ FDs
Find all of print album name and tracks of all of the albums by the composer James Hetfield, grouped by Album
What Does Data for Track Look Like?SELECT NAME, COMPOSER FROM CHINOOK.TRACK;
ANN.31
CSE4701
Another HW3 Hint –What about Problem 3.3c?
There are other Spellings to Consider: J. Hetfield
There are some Hetfields without First Name or Initial
What SQL Command is Needed for Searching Composer? LIKE is Used to Compare Partial Strings '%' (or '*') Replaces an Arbitrary # of characters
'_' replaces a single arbitrary character
SELECT FNAME, LNAMEFROM EMPLOYEEWHERE ADDRESS LIKE '%Houston,TX% '
ANN.32
CSE4701
Another HW3 Hint –What about Problem 3.4b and c?
Count and print the number of suppliers for each of the eight different categories of food which by name are: Beverages, Condiments, Confections, Dairy Products, Grains/Cereals, Meat/Poultry, Produce, Seafood
For each country (ShipCountry in Orders), total the Freight charges. The countries are: France, Germany, Brazil, Belgium, Switzerland, Venezuela, Austria, Mexico, USA, Sweden, Finland, Italy, Spain, UK, Ireland, Portugal, Canada, Denmark, Poland, Norway, Argentina
Need to use Both Grouping and Aggregation Operations See Slides 123 and 124 from Chapter 8
CSE 4701
Chapter 9-33
Announcements - Spring 2015February 10, 2015
Homework 2: Assigned Today Due – Monday, February 16, 11:59 pm
Submit to Homework 2 on HuskyCT Use Slide 7 of this PPT as basis for each
problem.
CSE 4701
Chapter 9-34
Look at 1st Problem Homework 27.23 3rd or 6.18 4th to 6th
a. How many copies of the Book titled “The last Tribe”Are owned by the library Branch whose name is “Sharpstown”?
What Tables are Needed?• Book and Book_Copies to find
the number of copies of“The Last Tribe” bookJoin on BookID
• Combine the result with theLibrary_Branch table for the“Sharpstown” BranchJoin on BrachID
CSE 4701
Chapter 9-35
a. How many copies of the Book titled “The last Tribe” Are owned by the library Branch whose name is “Sharpstown”?
Finding “The Last Tribe” book and its copies at each Bracnh
BOOKRES = BOOKCOPIES * (Title=‘The Lost Tribe’
(BOOK))) )
BookId
This gives us a result table linked on BookID for ‘The List Tribe” that has
rows for each library branch that has that book along with No_of_Copies
Finding “Sharpstown” Branch
BRANCHRES = BranchName=‘Sharpstown’
(LIBRARY-BRANCH))
This gives us a result table with the BrachID of ‘Sharpstown”
Combining the results
ANSWER = No_Of_Copies (BRANCHRES * BOOKRES))
BranchId
CSE 4701
Chapter 9-36
Name: Your name goes here
Finding “The Last Tribe” book and its copies at each Bracnh
BOOKRES = BOOKCOPIES * (Title=‘The Lost Tribe’
(BOOK))) )
BookId
Finding “Sharpstown” Branch
BRANCHRES = BranchName=‘Sharpstown’
(LIBRARY-BRANCH))
Combining the results
ANSWER = No_Of_Copies (BRANCHRES * BOOKRES))
BranchId
Problem 7.23a or 6.18a
CSE 4701
Chapter 9-37
Announcements - Spring 2015February 5, 2015
Homework 1: Due: Saturday, Feb 7, at 11:59pm. zip up the four files
LastName_Problem1.1.mwb LastName_Problem1.2.mwb LastName_Problem1.3.docx LastName_Problem1.4.docx into a LastName_FirstName_HMWK1.zip
Upload into Husky CT
CSE 4701
Chapter 9-38
Consider Requirements for Managing Books Across Multiple Branches of Library
Books and Branches have unique identifiers A book has a title, publisher, and pub date Publishers have names and contact info Authors need to be uniquely identified and associated
with the books that they have written Borrowers need to be uniquely identified and have
unique Library Card numbers and contact info A library has branches each with a unique ID Borrowers take out book loans at a given branch with
the data checked out and date due A library keeps track of all of the books including
potential multiple copies Design an EER diagram
CSE 4701
Chapter 9-39
Person
Author
Email LastNameFirstName
PersonID
WRITES
CSE 4701
Chapter 9-40
In Class ER/EER to Relational Conversion
CSE 4701
Chapter 9-41
What are Steps STEP 1: CONVERT EACH ENTITY
CREATE A TABLE STEP 2: WEAK ENTITIES
CREATE TABLE LINK TO STRONG STEP 3: 1-1 RELATIONSHIPS
INCLUDE FKEY IN ONE OF TWO STEP 4: 1- MANY
INCLUDE REFERNCE FKEY TO MANY SIDE STEP 5: MANY-MANY
NEW TABLE STEP 6: MULTI-VALUED
NEW TABLE STEP 7: N-ARY (3 or MORE)
NEW TABLE STEP 8: INHERITANCE
CSE 4701
Chapter 9-42
ER for Problem 1.1
Phone#
Patient
Drug
Physician
name
address email
SSN
status
price
name
expiration
name
email
address
specialtyPrimary
N 1
DEA#
Prescribes
refills N
N
dosage
dateFill
requirementpattern
Sold By
Purchasing Contract
start_date end_date
CSE 4701
Chapter 9-43
Tables for ER Diagram NOTE: For clarity used PNAME, MDNAME, DCNAME, DNAME STEP 1:
STEP 2: NO WEAK ENTITIES STEP 3: NO 1-1 RELATIONSHIPS STEP 4: 1- MANY – PATIENT & PRIMARY
PATIENT HAS 1 PRIMARY PHYSICIAN PHYSICIAN HAS MULTIPLE PATIENTS INCLUDE PNAME KEY INTO PATIENT NO ATTRIBUTES ON REALTION TO ADD: PATIENT (PNAME, ADDRESS, PHONE#, SSN, EMAIL,
MDNAME)
CSE 4701
Chapter 9-44
Tables for ER Diagram STEP 5: M – N RELATIONSHIPS
PRESCRIBES- BUILD A NEW TABLE WITH KEYS OF PATIENT, PHYSICIAN, and DRUG AND ADD ATTRIBUTES)
STEP 2: NO WEAK ENTITIES STEP 3: NO 1-1 RELATIONSHIPS STEP 4: 1- MANY – PATIENT & PRIMARY
PATIENT HAS 1 PRIMARY PHYSICIAN PHYSICIAN HAS MULTIPLE PATIENTS INCLUDE PNAME KEY INTO PATIENT NO ATTRIBUTES ON REALTION TO ADD: PATIENT (PNAME, ADDRESS, PHONE#, SSN, EMAIL,