1 / 17

ICOM 6005 – Database Management Systems Design

ICOM 6005 – Database Management Systems Design. Dr. Manuel Rodr í guez-Mart í nez Electrical and Computer Engineering Department Lecture 8 – September 18, 2001. Readings. Read: Chapter 3, The Relational Model of Data section 3.1.1 and section 3.4

aggie
Télécharger la présentation

ICOM 6005 – Database Management Systems Design

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

  3. Relational Instance: Students Information about enrolled students Dr. Manuel Rodriguez Martinez

  4. Relational Instance: Courses Information about courses being offered Dr. Manuel Rodriguez Martinez

  5. Relational Instance: Registration Information about student enrollment Dr. Manuel Rodriguez Martinez

  6. Renaming operator • Used to change the name of a relation and/or attributes in given relation • Useful to give to temporary relations results from relational expression. • Also good when two table have the attributes with the same names • Way to make attributes unique • Format (C(F), S) – rename relation S as C, and change attribute names in S as specified by rules in F. • F has the form {old_name1->new_name1, old_name2-> new_name2, …, old_nameN->new_nameN} • F can also be: F= {pos1 ->new_name1, pos2-> new_name2, … posN->new_nameN} Dr. Manuel Rodriguez Martinez

  7. Renaming Operator • The F argument is optional, in which case, we only change the name of the relation. • The S can also be optional, but it just does not make sense. • When won’t follow this use • Examples: • Name students with gqa greater than 3.50 as Dean’s List: • Name cross product of Student and Courses PotentialRegistration Dr. Manuel Rodriguez Martinez

  8. Rename operator • Change the name of sid field in Student to the name student_id Dr. Manuel Rodriguez Martinez

  9. Structured Query Language (SQL) • Structured Query Language (SQL) is the most common language to write queries to be run on a DBMS • SQL was introduced by IBM as part of projects SEQUEL-XRM and System-R. • Provides a mechanism to express relational queries in a easy to understand fashion. • SQL is based on: • Relation algebra • Relation calculus (not covered here) Dr. Manuel Rodriguez Martinez

  10. A Query in SQL • Get all students with gpa greater than 3.50. • Answer: SELECT * FROM Students S WHERE S.gpa > 3.50 • A query in SQL has the following structure: SELECT [Distinct] <Attribute-List> FROM <Table-List> WHERE <condition> Dr. Manuel Rodriguez Martinez

  11. Selection Example Dr. Manuel Rodriguez Martinez

  12. Projection Example Dr. Manuel Rodriguez Martinez

  13. Generalized Projection Dr. Manuel Rodriguez Martinez

  14. Join Example Dr. Manuel Rodriguez Martinez

  15. Outer-Join Example Dr. Manuel Rodriguez Martinez

  16. Union Example Dr. Manuel Rodriguez Martinez

  17. Nested Queries Dr. Manuel Rodriguez Martinez

More Related