cs 3630 database design and implementation. 2 dreamhome branch (branchno, street, city, state,...
TRANSCRIPT
![Page 1: CS 3630 Database Design and Implementation. 2 DreamHome Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3) Staff (staffNo, firstName,](https://reader036.vdocuments.net/reader036/viewer/2022082518/56649f045503460f94c18a2f/html5/thumbnails/1.jpg)
CS 3630 Database Design and Implementation
![Page 2: CS 3630 Database Design and Implementation. 2 DreamHome Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3) Staff (staffNo, firstName,](https://reader036.vdocuments.net/reader036/viewer/2022082518/56649f045503460f94c18a2f/html5/thumbnails/2.jpg)
2
DreamHomeBranch (branchNo, street, city, state, zipcode, phone1, phone2, phone3)
Staff (staffNo, firstName, lastName, position, address, DOB, salary, branchNo, branchAddress, branchPhone)
Owner (ownerNo, firstName, lastName, address, telNo)
PropertyForRent (propertyNo, street, city,state, zipcode, type, rooms, rent, ownerNo, ownerAddress, ownerName, ownerPhone, staffNo)
Client (clientNo, firstName, lastName, telNo, prefType, maxRent, staffNo, dateJoined, branchInfo)
Viewing (clientNo, propertyNo, viewDate, comment)
Lease (leaseNo, clientNo, propertyNo, rent, paymentMethod, deposit, duration, startDate, endDate)
Newspaper (paperName, address, phone, contact)
Common Attributes
![Page 3: CS 3630 Database Design and Implementation. 2 DreamHome Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3) Staff (staffNo, firstName,](https://reader036.vdocuments.net/reader036/viewer/2022082518/56649f045503460f94c18a2f/html5/thumbnails/3.jpg)
3
Query Examples
Produce a list from Staff, showing only lastName, firstName, staffNo, and salary.
Staff (staffNo, firstName, lastName, position,address, DOB, salary, branchNo, branchAddress, branchPhone)
lastName, firstName, staffNo, salary (Staff)
Order of attributes
![Page 4: CS 3630 Database Design and Implementation. 2 DreamHome Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3) Staff (staffNo, firstName,](https://reader036.vdocuments.net/reader036/viewer/2022082518/56649f045503460f94c18a2f/html5/thumbnails/4.jpg)
4
Query Examples
Produce a list of all Staff.
Staff (staffNo, firstName, lastName, position,address, DOB, salary, branchNo, branchAddress, branchPhone)
Retrieve all attributes when not specified.
* (Staff)
lastName, firstName, staffNo, salary, position, address, DOB, branchNo, branchAddress,
branchPhone (Staff)
Different order of attributes
![Page 5: CS 3630 Database Design and Implementation. 2 DreamHome Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3) Staff (staffNo, firstName,](https://reader036.vdocuments.net/reader036/viewer/2022082518/56649f045503460f94c18a2f/html5/thumbnails/5.jpg)
5
List all staff with a salary greater than $30,000.
Staff (staffNo, firstName, lastName, position,address, DOB, salary, branchNo, branchAddress, branchPhone)
(salary > 30000) (Staff)
All attributes when not specified
(salary > $30000) (Staff) // NO!
(salary > 30,000) (Staff) // NO!
![Page 6: CS 3630 Database Design and Implementation. 2 DreamHome Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3) Staff (staffNo, firstName,](https://reader036.vdocuments.net/reader036/viewer/2022082518/56649f045503460f94c18a2f/html5/thumbnails/6.jpg)
6
List lastName, firstName, staffNo and salary of all staff with a salary greater than $30,000.
lastName, firstName, staffNo, salary ((salary > 30000) (Staff))
(salary > 30000) (lastName, firstName, staffNo, salary (Staff))
![Page 7: CS 3630 Database Design and Implementation. 2 DreamHome Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3) Staff (staffNo, firstName,](https://reader036.vdocuments.net/reader036/viewer/2022082518/56649f045503460f94c18a2f/html5/thumbnails/7.jpg)
7
Construct a list of all cities where there is either a branch or a property.
Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3)PropertyForRent (propertyNo, street, city,state, zipcode, type, rooms, rent, ownerNo, ownerAddress, ownerName, ownerPhone, staffNo)
(city (Branch)) (city (PropertyForRent))
(city (Branch)) (city (PropertyForRent))
What is this?
![Page 8: CS 3630 Database Design and Implementation. 2 DreamHome Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3) Staff (staffNo, firstName,](https://reader036.vdocuments.net/reader036/viewer/2022082518/56649f045503460f94c18a2f/html5/thumbnails/8.jpg)
8
List the details of all staff members who manage a property in Madison.
Staff (staffNo, firstName, lastName, position, address, DOB, salary, branchNo, branchAddress, branchPhone)PropertyForRent (propertyNo, street, city,state, zipcode, type, rooms, rent, ownerNo, ownerAddress, ownerName, ownerPhone, staffNo)
Common attribute?
Staff PropertyForRent
Staff.* ( city = ‘Madison’(Staff PropertyForRent))
Staff ( staffNo ( city = ‘Madison’ (PropertyForRent)))
![Page 9: CS 3630 Database Design and Implementation. 2 DreamHome Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3) Staff (staffNo, firstName,](https://reader036.vdocuments.net/reader036/viewer/2022082518/56649f045503460f94c18a2f/html5/thumbnails/9.jpg)
9
Staff.* ( city = ‘Madison’(Staff PropertyForRent))
* ( city = ‘Madison’(Staff PropertyForRent)) all attributes from both tables
Staff.* ( city = Madison(Staff PropertyForRent))What is Madison? An identifier
Staff.* ( city = “Madison” (Staff PropertyForRent))What is “Madison”? Could be anything but a string
![Page 10: CS 3630 Database Design and Implementation. 2 DreamHome Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3) Staff (staffNo, firstName,](https://reader036.vdocuments.net/reader036/viewer/2022082518/56649f045503460f94c18a2f/html5/thumbnails/10.jpg)
10
List the clientNo, lastName and firstName of all clients who have viewed a property.
Client (clientNo, firstName, lastName, telNo, prefType, maxRent, staffNo, dateJoined, branchInfo)
Viewing (clientNo, propertyNo, viewDate, comment)
Client.clientNo, lastName, firstName
( Client.clientNo = Viewing.clientNo (Client Viewing))
Client.clientNo, lastName, firstName (Client Viewing))
One client may have reviewed a number of properties,
but should be in the result at most once.
![Page 11: CS 3630 Database Design and Implementation. 2 DreamHome Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3) Staff (staffNo, firstName,](https://reader036.vdocuments.net/reader036/viewer/2022082518/56649f045503460f94c18a2f/html5/thumbnails/11.jpg)
11
List the clientNo, lastName and firstName of all clients who have viewed a property.
Also include the properties (propertyNo) they viewed with the date and their comments on the properties
Client (clientNo, firstName, lastName, telNo, prefType, maxRent, staffNo, dateJoined, branchInfo)
Viewing (clientNo, propertyNo, viewDate, comment)
Client.clientNo, lastName, firstName, propertyNo, viewDate, comment
(Client Viewing)
One client may have reviewed a number of properties,
And may be in the result multiple times.
![Page 12: CS 3630 Database Design and Implementation. 2 DreamHome Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3) Staff (staffNo, firstName,](https://reader036.vdocuments.net/reader036/viewer/2022082518/56649f045503460f94c18a2f/html5/thumbnails/12.jpg)
12
List all Properties that have been viewed this year.
Assume there is a function CurrentDate that returns the current date, including year, month, and day.
PropertyForRent (propertyNo, street, city,state, zipcode, type, rooms, rent, ownerNo, ownerAddress, ownerName, ownerPhone, staffNo)
Viewing (clientNo, propertyNo, viewDate, comment)
Common attribute?
PropertyForRent.* (viewDate.Year = CurrentDate.Year
(PropertyForRent Viewing))
![Page 13: CS 3630 Database Design and Implementation. 2 DreamHome Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3) Staff (staffNo, firstName,](https://reader036.vdocuments.net/reader036/viewer/2022082518/56649f045503460f94c18a2f/html5/thumbnails/13.jpg)
13
Produce a status report on all properties
Each property
Show propertyNo, street, city
Also show clientNo, viewDate, and comment from each viewing
if the property has been viewed,
(Otherwise, use null for the three fields)
PropertyForRent (propertyNo, street, city,state, zipcode, type, rooms, rent, ownerNo, ownerAddress, ownerName, ownerPhone, staffNo)Viewing (clientNo, propertyNo, viewDate, comment)
PropertyForRent.propertyNo, street, city, clientNo, viewDate, comment
(PropertyForRent Viewing)
![Page 14: CS 3630 Database Design and Implementation. 2 DreamHome Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3) Staff (staffNo, firstName,](https://reader036.vdocuments.net/reader036/viewer/2022082518/56649f045503460f94c18a2f/html5/thumbnails/14.jpg)
14
List all pairs of clients (firstName, lastName, telNo) and owners (firstName, lastName, telNo)
if the client has viewed a property owned by the owner. (Use C for Client and O for Owner)
Client (clientNo, firstName, lastName, telNo, prefType, maxRent, staffNo, dateJoined, branchInfo)Owner (ownerNo, firstName, lastName, address, telNo, type )Viewing (clientNo, propertyNo, viewDate, comment)PropertyForRent (propertyNo, street, city,state, zipcode, type, rooms, rent, ownerNo, ownerAddress, ownerName, ownerPhone, staffNo)
Client Viewing PropertyForRent Owner
C.firstName, C.lastName, C.telNo, O.firstName, O.lastName, O.telNo
( (Client Viewing) (PropertyForRent Owner) )
Common attributes?
![Page 15: CS 3630 Database Design and Implementation. 2 DreamHome Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3) Staff (staffNo, firstName,](https://reader036.vdocuments.net/reader036/viewer/2022082518/56649f045503460f94c18a2f/html5/thumbnails/15.jpg)
15
List all pairs of clients (firstName, lastName, telNo) and owners (firstName, lastName, telNo)
if the client has viewed a property owned by the owner. (Use C for Client and O for Owner)
Client (clientNo, firstName, lastName, telNo, prefType, maxRent, staffNo, dateJoined, branchInfo)Owner (ownerNo, firstName, lastName, address, telNo)Viewing (clientNo, propertyNo, viewDate, comment)PropertyForRent (propertyNo, street, city,state, zipcode, type, rooms, rent, ownerNo, ownerAddress, ownerName, ownerPhone, staffNo)
Client Viewing PropertyForRent Owner
Client (Viewing PropertyForRent ) Owner
(Client PropertyForRent ) (Viewing Owner)
What’s the common attribute?
![Page 16: CS 3630 Database Design and Implementation. 2 DreamHome Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3) Staff (staffNo, firstName,](https://reader036.vdocuments.net/reader036/viewer/2022082518/56649f045503460f94c18a2f/html5/thumbnails/16.jpg)
16
Assignment 2
Due Friday, at beginning of class
How to get the symbols?