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

Slides:



Advertisements
Similar presentations
Relational Algebra and Relational Calculus
Advertisements

Assignment Design Methodology A structured approach that uses procedures, techniques, tools, and documentation aids to support and facilitate the.
CSC271 Database Systems Lecture # 11.
Chapter 3 CIS 458 Sungchul Hong
RELATIONAL ALGEBRA Lecture Relational Algebra Operations to manipulate relations. Used to specify retrieval requests (queries). Query results in.
CSC271 Database Systems Lecture # 13. Summary: Previous Lecture  Grouping through GROUP BY clause  Restricted groupings  Subqueries  Multi-Table queries.
Branch (Bno, Street, Area, City, Pcode, Tel_No, Fax_NO) Staff (Sno, FName, LName, Address, Tel_No, Position, Sex, DOB, Salary, NIN, Bno) Property_for_Rent.
Lesson II The Relational Model © Pearson Education Limited 1995, 2005.
1 Minggu 3, Pertemuan 5 Relational Algebra (Cont.) Matakuliah: T0206-Sistem Basisdata Tahun: 2005 Versi: 1.0/0.0.
Chapter 6 SQL: Data Manipulation. 2 Objectives of SQL u Database language should allow user to: –create database and relation structures –perform insertion,
1 Design Methodology A structured approach that uses procedures, techniques, tools, and documentation aids to support and facilitate the process of design.
1 CS 3630 Database Design and Implementation. 2 Final Exam 7:00 – 8:52 PM, Thursday, May 16 Section 1: Ull 009 Section 2: Ull Points –50 points.
Database Systems: A Practical Approach to Design, Implementation and Management International Computer Science S. Carolyn Begg, Thomas Connolly Lecture.
Chapter 6 SQL: Data Manipulation Cont’d. 2 ANY and ALL u ANY and ALL used with subqueries that produce single column of numbers u ALL –Condition only.
1-1 Thomas Connolly and Carolyn Begg’s Database Systems: A Practical Approach to Design, Implementation, and Management Chapter 4 Part One: Relational.
Relational Database Management System A type of database in which records are stored in relational form is called relational database management system.
Introduction to Databases. Case Example: File based Processing Real Estate Agent’s office Property for sale or rent Potential Buyer/renter Staff/employees.
Relational Model & Relational Algebra. 2 Relational Model u Terminology of relational model. u How tables are used to represent data. u Connection between.
CSC271 Database Systems Lecture # 10.
1 Test1 N = {n: n is an integer and n  0} X = {x: x = n + 5, where n  N} Y = {y: y = 7 * n - 1, where n  N} List the three smallest elements of each.
Data Manipulation Using MySQL tMyn1 Data Manipulation Using MySQL Ideally, a database language should allow a user to: –Create the database and relation.
SQL: Overview SQL Overview © Pearson Education Limited 1995, 2005.
CSC271 Database Systems Lecture # 12. Summary: Previous Lecture  Row selection using WHERE clause  WHERE clause and search conditions  Sorting results.
Chapter 6 SQL: Data Manipulation (Advanced Commands) Pearson Education © 2009.
Chapter 9 Methodology - Logical Database Design Chapter 16 in Textbook.
SQL Data Manipulation II Chapter 5 CIS 458 Sungchul Hong.
Chapter 8 Methodology - Conceptual Database Design Chapter 15 in Textbook.
Chapter 5 SQL: Data Manipulation © Pearson Education Limited 1995, 2005.
Bayu Adhi Tama, ST., MTI. Introduction Relational algebra and relational calculus are formal languages associated with the relational.
Advanced Database Systems
1 Pertemuan > > Matakuliah: >/ > Tahun: > Versi: >
CS 3630 Database Design and Implementation. 2 E-R Model (II) Keys To identify records in a table Candidate Key Primary Key Alternate Key Composite Key.
1 E-R Model (II) Keys To identify records in a table Candidate Key Primary Key Alternate Key Composite Key.
CS 3630 Database Design and Implementation. Assignment 1 2 What is 3630?
Chapter 7 SQL: Data Manipulation Chapter #6 in the textbook Pearson Education © 2009.
CS 3630 Database Design and Implementation. Database Schema Branch (Bno…) Staff (Sno…Bno) Owner (Ono…) PropertyForRent (Pno…Ono) Renter (Rno…) Viewing.
Chapter 5 Relational Algebra and Relational Calculus Pearson Education © 2009.
IST 210 SQL Todd Bacastow IST 210: Organization of Data.
Chapter 5 Relational Algebra Pearson Education © 2014.
CSC271 Database Systems Lecture # 8. Summary: Previous Lecture  Relation algebra and operations  Selection (Restriction), projection  Union, set difference,
Schema Conversion Create a table for each entity –1:1 choose one side and put a foreign key –1:* put a foreign key in many side –*:* create a table for.
1 Pertemuan > > Matakuliah: >/ > Tahun: > Versi: >
Modelling Methodologies Chapter 16, 17, 18. Modeling Methodologies2 Database Design Physical DB design Logical DB design Conceptual DB design Hardware.
Chapter 4 Practice Problem Solutions. A list (Bno, Street, Area,Tel_No, Fax_No) of branches located in Bay Area Branch (Bno, Street, Area, City, Pcode,
Quiz Where to Store Attributes of Relationship Staff (1) Interviews (0..*) Client Attributes: date, time, comment Staff (StaffNo, …) PK: StaffNo.
Chapter 5 Relational Algebra and Relational Calculus Pearson Education © 2014.
SQL: Additional Notes. 2 Example 5.3 Use of DISTINCT List the property numbers of all properties that have been viewed. SELECT propertyNo FROM Viewing;
LECTURE THREE RELATIONAL ALGEBRA 11. Objectives  Meaning of the term relational completeness.  How to form queries in relational algebra. 22Relational.
Chapter 4 Relational Algebra Chapter 4 in Textbook.
Teacher Workshop Database Design Pearson Education © 2014.
Chapter 11 SQL: Data Manipulation
Relational Algebra Lecture 2.
CS 3630 Database Design and Implementation
CS 3630 Database Design and Implementation
CS 3630 Database Design and Implementation
CS 3630 Database Design and Implementation
CS 3630 Database Design and Implementation
Relational Algebra and Relational Calculus
The Relational Database Model
Chapter Name SQL: Data Manipulation Chapter #6 in the textbook
Chapter Name SQL: Data Manipulation Chapter #6 in the textbook
Conceptual Database Design
Chapter Name SQL: Data Manipulation
Quiz 1 1. Given two sets S = {3, 5, 7} and T = {2, 4, 6}. List all elements of the following set: {(s, t) | (s, t)  S  T and s + t = 9} Result (3, 6)
CS 3630 Database Design and Implementation
Logical Database Design
SQL – Data Manipulation
Chapter Name SQL: Data Manipulation
The Relational Algebra
Presentation transcript:

CS 3630 Database Design and Implementation

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 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 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 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 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 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 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  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 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 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 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 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 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 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 Assignment 2 Due Friday, at beginning of class How to get the symbols?  