# cse4701ann

```Announcements – Fall 2015
October 6, 2015

CSE4701

Homework 3 – Due Friday Oct 9, 11:59pm
 Part A: Design and ER Diagram from Written
 Part B: EER to Relation Translation
Midterm Exam – We will Review on Thurs 10/8
 Tuesday Oct 13, 5:00-6:30pm ITE134 & 138

Sample Exam and Soln:
 http://www.engr.uconn.edu/~steve/Cse4701/cse4701mtexamsp15.pdf
 http://www.engr.uconn.edu/~steve/Cse4701/cse4701mtexamsoln.pptx

Use BBALL Sample Schema
 http://www.engr.uconn.edu/~steve/Cse4701/cse4701BBall.doc
ANN.1
Homework 3 – Part A
ER Diagram Design

CSE4701


Construct ER Diagram (no Inheritance) for Peoplesoft
 Basic Demo: Name, NetID, Email, Peoplesoft#, Major,
Minor etc.
 Departments – Name, Code, School, etc.
 Courses - Dept, Num, Name, Descr, Credits, etc.
 Offerings – Course/Instructot, Yr, Sem, Section, etc.
 Grad report (per course and its offering)
 Planned Schedule (Shopping Cart)
 Supporting registration process/rosters/waitlists
 Supporting Plan of Study
Augment requirements with your own assumptions
Recommend – use the PPT in cse4701hw3.docx
 Right Click – Presentation Object – Open –
 opens powerpoint so you can save as a PPT to modify
ANN.2
Homework 3 – Part B
EER to Relational Conversion

CSE4701



Given a EER for Pharmacy with Patients, Physicians,
Drugs, Companies, etc.
Basic Tracking Info Defined
Scenario of usage explained
EER Diagram provided
ANN.3
Homework 3 – Part B
EER to Relational Conversion
CSE4701
ANN.4
Algorithm for EER to Relat Conversion

CSE4701 






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
ANN.5
In Class Exercise 1 – 9/29/15 Class

Convert the Following Diagram to a Equivalent Set
of relational tables
CSE4701
ANN.6
EER to Relat Algorithm Steps

CSE4701







STEP 1: CONVERT EACH ENTITY

CREATE A TABLE
STEP 2: WEAK ENTITIES

STEP 3: 1-1 RELATIONSHIPS

INCLUDE FKEY IN ONE OF TWO
STEP 4: 1- MANY

INCLUDE REFERNCE FKEY TO MANY
STEP 5: MANY-MANY

NEW TABLE
STEP 6: MULTI-VALUED

NEW TABLE
STEP 7: N-ARY (3 or MORE)

NEW TABLE
STEP 8: INHERITANCE
ANN.7
What are Necessary Steps?

CSE4701

STEP 1: CONVERT EACH ENTITY

CREATE A TABLE for BANK, CUSTOMER, AND ACCOUNT:




ACCOUNT(ACCTNO, BALANCE, TYPE)
LOAN(LOANNO, AMOUNT, TYPE)
STEP 2: WEAK ENTITIES



STEP 4: 1- MANY

INCLUDE REFERNCE FKEY TO MANY SIDE – ADD BNO
˃ACCOUNT(ACCTNO, BALANCE, TYPE, BNO)
STEP 5: MANY-MANY

NEW TABLES
 LOAN(LOANNO, AMOUNT, TYPE, BCODE, BNO)
 A_C(SSN, ACCTNO)
 L_C(SSN, LOANNO)
ANN.8
In Class Exercise 2

Convert the Following Diagram to a Equivalent Set
of relational tables
CSE4701
ANN.9
EER to Relat Algorithm Steps

CSE4701





STEP 1: CONVERT EACH ENTITY

CREATE A TABLE
STEP 2: WEAK ENTITIES

STEP 3: 1-1 RELATIONSHIPS

INCLUDE FKEY IN ONE OF TWO
STEP 4: 1- MANY

INCLUDE REFERNCE FKEY TO MANY
STEP 5: MANY-MANY

NEW TABLE
STEP 6: MULTI-VALUED

NEW TABLE
ANN.10
What are Necessary Steps?

CSE4701

STEP 1: CONVERT EACH ENTITY

CREATE TABLES for

SHIP, SHIP_TYPE, STATE_COUNTRY, SEAOCEANLAKE:




SHIP(SNAME, OWNER)
SHIP_TYPE ( TYPE, TONNAGE, HULL)
STATE_COUNTRY(NAME, CONTINENT)
SEAOCEANLAKE (NAME)
STEP 2: WEAK ENTITIES

 SHIP_MOVEMENT(SSNAME, DATE, TIME, LONG,
LAT)
 PORT(PNAME, S_C_NAME, S_O_L_NAME)
 VISIT(VSNAME, VPNAME, STARTDATE, ENDDATE)

STEP 4: 1- MANY

INCLUDE REFERNCE FKEY TO MANY SIDE – ADD TYPE, NAME
 SHIP(SNAME, OWNER, TYPE, PNAME)
ANN.11
In Class Mega Exercise 3
User
UName
UState
UPasswd
UFName
ULName
UStreet1
UStreet2
UCity
UZip
UEmail
Uphone
UFax
UCell
UHomePage
CSE4701
o
APrivileges
AExpirDate
APasswd
Seeker
Payment
PaymentID
PAmount
PStatus
PDate
Invoice
INumber
IDate
d
Poster
PPosition
PContactEmail
Two Inheritance Hierarchies for UConnJobSearch.
CreditCard
CCNumber
CCType
CCExpirDate
CCDate
BankPayment
BName
BNumber
BAcctNumber
OnLineService
SName
STransID
SFee
ANN.12
In Class Mega Exercise 3
Education
EUniversity
EDegreeType
EDegreeArea
EGPA
EStartDate
n
DEGREES
Seeker
1
1
CSE4701
Poster
PPosition
PContactEmail
1
Company
CName
CStreet1
CStreet2
CCity
CZip
CEmail
CPhone
CFax
CCell
CHomePage
1
WORKS
FOR
LISTS
1
1
1
ApplicationID
Resume
ResumeID
RLName
RFName
RObjective
RSalaryMin
RFileName
RFilePath
1
PRIOR
JOBS
n
POST&PAY
1
1
n
Payment
PaymentID
PAmount
PStatus
PDate
JOBS
LIST
n
APPLIES
n
Job
JobID
JListDate
JobTitle
JCity, JZip
Jduties
JYRSExperience
**JDegreeTypes
**JDegreeAreas
JLowRange
JHighRange
JFillStatus
n
DateApplied
SKILL
SET
n
1
JOB
SKILLS
n
Skill
SSkillID
SSkillName
PriorJobs
PJCompanyName
PJJobTitle
PJDuties
PJCity
PJState
PJStartDate
PJEndDate
**Attributes are multi-valued attributes
Remaining Entities and Relationships for UConnJobSearch.
ANN.13
EER to Relat Algorithm Steps

CSE4701







STEP 1: CONVERT EACH ENTITY

CREATE A TABLE
STEP 2: WEAK ENTITIES

STEP 3: 1-1 RELATIONSHIPS

INCLUDE FKEY IN ONE OF TWO
STEP 4: 1- MANY

INCLUDE REFERNCE FKEY TO MANY
STEP 5: MANY-MANY

NEW TABLE
STEP 6: MULTI-VALUED

NEW TABLE
STEP 7: N-ARY (3 or MORE)

NEW TABLE
STEP 8: INHERITANCE
ANN.14
Step 1: Regular Entities

CSE4701





USER (UName, UState, UPasswd, UFName, ULName,
UStreet1, UStreet2, UCity, UZip, UEmail, UPhone,
UFax, UCell, UHomepage)
COMPANY (CName, CStreet1, CStreet2, CCity, CZip,
CEmail, CPhone, CFax, CCell, CHomepage)
RESUME (ResumeID, RLName, RFName, RObjective,
RSalaryMin, RFileName, RFilePath)
SKILL (SSkillID, SSkillName)
PAYMENT (PaymentID, UName, PAmount, PStatus,
PDate)
JOB (JobID, CName, JListDate, JobTitle, JCity, JZip,
JDuties, JYrsExperience, **JDegreeTypes,
**JDegreeAreas, JLowRange, JHighRange,
JFillStatus)
ANN.15
Step 2: Weak Entities

CSE4701

EDUCATION (ResumeID, EUniversity, EDegreeType,
PRIORJOBS (ResumeID, PJCompanyName,
PJJobTitle,
PJDuties, PJCity, PJState,
PJStartDate, PJEndDate)
ANN.16
Step 8: Subclasses (Do before Step 3)

CSE4701






APasswd)
SEEKER (UName)
POSTER (UName, PPosition, PContactEmail)
INVOICE (PaymentID, INumber, IDate)
CREDITCARD (PaymentID, CCNumber, CCType,
CCExpirDate, CCDate)
BANKPAYMENT (PaymentID, BName, BNumber,
BAcctNumber)
ONLINESERVICE (PaymentID, SName, STransID,
SFee)
ANN.17
Steps 3, 4 & 7: 1-1,1-m, m-n, n-ary

1-1

CSE4701


RESUME (ResumeID, UName, RLName, RFName,
RObjective, RSalaryMin, RFileName, RFilePath)
SEEKER (UName, ResumeID)
1-m

JOB (JobID, CName, JListDate, JobTitle, JCity,
JZip, JDuties, JYrsExperience, **JDegreeTypes,
**JDegreeAreas, JLowRange, JHighRange,
JFillStatus, ApplicationID, Applicant,
DateApplied)

m-n

REQUIRESSKILL (JobID, SkillID)
 HASSKILL (ResumeID, SkillID)
n-ary - POST&PAY (Poster, PaymentID, JobID)

ANN.18
Step 6: Multi-valued Attributes

CSE4701

 DEGREETYPE (CName, JobID, JDegreeType)
 DEGREEAREA (CName, JobID, JDegreeArea)
Change:
 JOB (JobID, CName, JListDate, JobTitle, JCity, JZip,
JDuties, JYrsExperience, **JDegreeTypes,
**JDegreeAreas, JLowRange, JHighRange, JFillStatus)
To
JOB (JobID, CName, JListDate, JobTitle, JCity, JZip,
JDuties, JYrsExperience, JLowRange, JHighRange,
JFillStatus, ApplicationID, Applicant, DateApplied)
ANN.19
Final Set of Tables

CSE4701







USER (UName, UState, UPasswd, UFName, ULName, UStreet1,
UStreet2, UCity, UZip, UEmail, UPhone, UFax, UCell,
UHomepage)
COMPANY (CName, CStreet1, CStreet2, CCity, CZip, CEmail,
CPhone,
CFax, CCell, CHomepage)
RESUME (ResumeID, UName, RLName, RFName, RObjective,
RSalaryMin, RFileName, RFilePath)
SKILL (SSkillID, SSkillName)
PAYMENT (PaymentID, UName, PAmount, PStatus, PDate)
JOB (JobID, CName, JListDate, JobTitle, JCity, JZip, JDuties,
JYrsExperience, JLowRange, JHighRange, JFillStatus,
ApplicationID,
Applicant, DateApplied)
EDUCATION (ResumeID, EUniversity, EDegreeType, EDegreeArea,
PRIORJOBS (UName, PJCompanyName, PJJobTitle, PJDuties, PJCity,
PJState, PJStartDate, PJEndDate)
ANN.20
Final Set of Tables



CSE4701









SEEKER (UName, ResumeID)
POSTER (UName, CName, PPosition, PContactEmail)
INVOICE (PaymentID, INumber, IDate)
CREDITCARD (PaymentID, CCNumber, CCType, CCExpirDate,
CCDate)
BANKPAYMENT (PaymentID, BName, BNumber, BAcctNumber)
ONLINESERVICE (PaymentID, SName, STransID, SFee)
REQUIRESSKILL (JobID, SkillID)
HASSKILL (ResumeID, SkillID)
DEGREETYPE (CName, JobID, JDegreeType)
DEGREEAREA (CName, JobID, JDegreeArea)
POST&PAY (Poster, PaymentID, JobID)
ANN.21
Announcements – Fall 2015
September 15

CSE4701 
Homework 2 – Basic and Advanced SQL
 Northwind and Chinook DBs
Eight Problems – 4 on Each Schema
ANN.22
Homework 2 - Two 4 part Problems


CSE4701 

Due: Monday 9/21, 11:59pm
Instructions to load DB and perform SQL queries
Chinook Database Sample: Digital media store,
tables for artists, albums, media tracks, etc.
 https://chinookdatabase.codeplex.com/
NorthwindExtended Database Sample –
Database of Employees, Customers, Suppliers,
etc.
ANN.23
Northwind Schema
CSE4701
ANN.24
Homework Problem 2.1: Chinook

CSE4701



Find all of the playlist(s) that contain the largest number of
pop tracks and return the artist name and amount of tracks.
Find all artist(s) that have the most tracks classified as
“Rock”, “Jazz”, “Rock And Roll”, “Pop”, and “Classical”,
sorted by Genre Name and then by Artist name, and return
the artist name, genre, and amount of tracks. Note that more
than one artist may have ths ame number of most tracks.
Find the name of the artist and the name of each track for all
artists with more than 5 tracks. Note that an artist can have
multiple tracks without having an album.
For the artist “AC/DC”, find the playlist(s) which contains
the most tracks. Return the artist and Name of the Playlist.
There may be more than one playlist with the most tracks.
ANN.25
Chinook Schema
CSE4701
ANN.26
Homework Problem 2.2: Northwind

CSE4701



Find the list of all customers from United Kingdom sorted
by Company Name in ascending order and return the
company Name and Country.
Find the number of customers that are located in each
country. Your query should return just a number
representing the number of customers who are located in
each country.
Find the product ID, Product Name, UnitsInStock,
ReorderLevel, and the shortage amount (sorted by Shortage
amount in Descending order) where the ShoratgeAmount is
a calculated column and it is defined as ShortageAmount:
ReorderLevel - UnitsInStock Hint: Only list products that
that have ShortageAmount > 0
Find the Product Name, UnitPrice, and UnitsInStock and
ANN.27
Initial MySQL Workbench Screen
CSE4701
ANN.28
Instructions – import .sql file
CSE4701
ANN.29
Instructions – Query DB
CSE4701
ANN.30
Instructions – Query DB
CSE4701
ANN.31
Instructions – Generate EER
CSE4701
ANN.32
Instructions – Generate EER
CSE4701
ANN.33
Instructions – Generate EER
CSE4701
ANN.34
CSE4701
Chinook
EER
ANN.35
https://chinookdatabase.codeplex.com/wikipage?title=
Chinook_Schema&referringTitle=Documentation
CSE4701
ANN.36
Albums and Tracks
If you want to see data:
SELECT * FROM CHINOOK.ALBUM;
CSE4701
SELECT * FROM CHINOOK.TRACK;
ANN.37
Explaining Chinook Schema

CSE4701 




Employees and Customers are Two Main DB
Users
Repository Track Artists and Their Albums
Each Album has Multiple Tracks
Tracks are of a Particular Media and Genre
Customers can Also Create Playlists of Tracks
Customers have Invoices
 Each Invoice has Multiple Lines
 Each Line References one Track
ANN.38
Another HW3 Hint –

CSE4701

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.39
Another HW3 Hint –

CSE4701 

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, LNAME
FROM EMPLOYEE
ANN.40
Explaining Northwind Schema


CSE4701 





Suppliers: A Suppliers Contact Info and web link.
Products: Names, suppliers, and Prices
Categories: Categories of Northwind products such
as Beverages, Condiments, Confections, Dairy
Products, Grains/Cereals, Meat/Poultry, Produce,
Seafood
Orders: For each Customer with dates &Shipping
Order Details: Products, quantities, and price.
Employees: Typical Info.
Customers: Typical Info.
Shippers: Typical Info.
ANN.41
Northwind Schema
CSE4701
Northwind
EER
ANN.42
SELECT * FROM NORTHWIND.PRODUCTS;
CSE4701
ANN.43
Another HW3 Hint –
What about Problem 3.4b and c?

CSE4701


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,
Need to use Both Grouping and Aggregation Operations
 See Slides 123 and 124 from Chapter 8
ANN.44
Announcements – Fall 2015
September 8


CSE4701
Homework 1: Assigned Today
Due – Monday, September 14, 11:59 pm
 Submit to Homework 1 on HuskyCT
ANN.45
Homework 1 – 5 Problems

Writing Relational Algebra Queries
Utilizing the TV/Movie Schema – pgs 2 and 3

http://www.engr.uconn.edu/~steve/Cse4701/cse4701hw1.pdf

CSE4701
ANN.46
Homework 1 – 5 Problems
Explaining the Tables


CSE4701





Person Table: A person can be a Director or an Actor.
TVShows Table: ShowName in combination with
StartYear forms the key.
Episodes Table: For each TV Show, the Episodes for its
entire run (all years in sequential order)
Movies Table: MovieName in combination with Year forms
the key.
Roles Table: Roles are tracked by Show (Movie or TV).
TVRoles and MovieRoles Tables: Actors are identified by
the roles that they play in a given show.
TVDirector and MovieDirectors Tables: Directors are
identified by the movies and TV shows they direct in a year.
ANN.47
Third Page Shows Tuples
CSE4701
ANN.48
Third Page Shows Tuples
CSE4701
ANN.49
Five Problems

CSE4701




Find the names (Last and First) and State of

All persons that were in a Movie in 1997

All persons that were in a TV show in 1987.
 All persons that were in either a Movie in 1997 or a TV show in
1987
 All persons that were in both a Movie in 1997 or a TV show in
1987
Find the last names (Last and First) of the directors for all Movies and
TV Shows that have the same name (TV Show and Movie have the
same names).
Find the names (Last and First Name) of all actors and their roles for
“Friends” for Episodes 11 to 25.
Find the names (Last and First) that played the same Role in a TV and a
Movie who won an Emmy for the TV role but did not win an Oscar for
the Movie role.
Find the names of all Shows or Movies that have won an Emmy (TV
Show) or Oscar (Movie).
ANN.50
Let’s Look at Problem 1a

CSE4701 

Find the names (Last and First) and State of All
persons that were in a Movie in 1997
What are Tables that we Need?
 Movies to get 1997 Movies by Year
 MovieRoles to Find the PersonID for all Actors
in those Movies
 Person to Use to Find Last/First Names
Identify Needed Info by Table and How Link
ANN.51
Let’s Look at Problem 1a
Find the names (Last and First) and State of All
persons that were in a Movie in 1997
Find the Movies in 1997

CSE4701 
Movies1997(ShowID)
= ShowID (
Year=1997 (Movies))
Find the Actors in those Movies by Movie Roles

MovieActors(PersonID) =
PersonID(
Link those Actors to the Person Table

Movies1997.ShowID=MovieRoles.ShowID (Movies1997 x MovieRoles))
=
Lname,Fname,State(Person.PersonID
= AllActors.PersonID(Person x MovieActors))
ANN.52
```
###### Document
Category
Без категории
Views
11
File Size
1 989 Кб
Tags
1/--pages
Пожаловаться на содержимое документа