Presentation is loading. Please wait.

Presentation is loading. Please wait.

ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez-Martínez Electrical and Computer Engineering Department Lecture 10 – September 18,

Similar presentations


Presentation on theme: "ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez-Martínez Electrical and Computer Engineering Department Lecture 10 – September 18,"— Presentation transcript:

1 ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez-Martínez Electrical and Computer Engineering Department Lecture 10 – September 18, 2001

2 ICOM 6005Dr. Manuel Rodriguez Martinez2 Readings Read: –Chapter 3, The Relational Model of Data section 3.1.1 and section 3.4 –Chapter 5, SQL: Queries, Programming, Triggers

3 ICOM 6005Dr. Manuel Rodriguez Martinez3 Relational Instance: Students sidnameloginagegpa 9291Marymary@ece304.00 1234Manuelmanu@ece183.50 6767Josejoe@ece253.10 3229Bobbybob@ece193.90 9987Rafaelrafy@ece292.75 8901Luzluz@ece214.00 Information about enrolled students

4 ICOM 6005Dr. Manuel Rodriguez Martinez4 Relational Instance: Courses cidsectionnameroom 80101English I333 80102English I333 80103English I333 80741Databases123 80742Databases124 80751Electronics230 80871Calculus276 Information about courses being offered

5 ICOM 6005Dr. Manuel Rodriguez Martinez5 Relational Instance: Registration cidsectionsid 807411234 808711234 801016767 801018901 801023229 807519291 808711234 Information about student enrollment

6 ICOM 6005Dr. Manuel Rodriguez Martinez6 Projection Example Get the all the course ids and section numbers for all courses. –Answer: SELECT cid, section FROM Courses –In this case result is a set cidsection 80101 2 3 80741 2 80751 80871

7 ICOM 6005Dr. Manuel Rodriguez Martinez7 Projection Example 2 Get all the course ids for all courses. SELECT cid FROM Courses –In this case, result is not a set To make it a set: Get all the course id for all courses, removing duplicates SELECT distinct cid FROM Courses cid 8010 8074 8075 8087 cid 8010 8074 8075 8087

8 ICOM 6005Dr. Manuel Rodriguez Martinez8 Generalized Projection Get the name and login domain for all students with GPA greater than 3.50. The domain is a user-defined function that extract the domain part from a login address. –Ex. domain(manuel@ece) = ece SQL Query: SELECT name, domain(login) FROM Students WHERE gpa > 3.50 namedomain(login) Maryece Bobbyece Luzece

9 ICOM 6005Dr. Manuel Rodriguez Martinez9 Join Example Basic join format let’s you add the equi-join condition in the WHERE clause. Get the name, login id and gpa of all students enrolled in the course with cid 8010 SELECT S.name, S.login, S.gpa FROM Students S, Registration R WHERE S.sid = R.sid S.nameS.loginS.gpa Josejoe@ece3.10 Bobbybob@ece3.90 Luzluz@ece4.00

10 ICOM 6005Dr. Manuel Rodriguez Martinez10 Outer-Join Example

11 ICOM 6005Dr. Manuel Rodriguez Martinez11 Union Example

12 ICOM 6005Dr. Manuel Rodriguez Martinez12 Nested Queries


Download ppt "ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez-Martínez Electrical and Computer Engineering Department Lecture 10 – September 18,"

Similar presentations


Ads by Google