Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 3630 Database Design and Implementation. 2 DreamHome Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3) Staff (staffNo, firstName,

Similar presentations


Presentation on theme: "CS 3630 Database Design and Implementation. 2 DreamHome Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3) Staff (staffNo, firstName,"— Presentation transcript:

1 CS 3630 Database Design and Implementation

2 2 DreamHome Branch (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

3 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

4 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

5 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!

6 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))

7 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?

8 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)))

9 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

10 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.

11 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.

12 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))

13 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)

14 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?

15 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?

16 16 Assignment 2 Due Friday, at beginning of class How to get the symbols?  


Download ppt "CS 3630 Database Design and Implementation. 2 DreamHome Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3) Staff (staffNo, firstName,"

Similar presentations


Ads by Google