1 / 21

The Relational Model

The Relational Model. DB Chapter 2 (and some from chapter 4, 5). J.G. Zheng June 27 th 2005. Overview. Relational model terminologies and foundations Some design concepts. Introduction. Edgar F. Codd, 1970 One sentence to explain relational database model:

basil-nash
Télécharger la présentation

The Relational Model

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. The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27th 2005

  2. Overview • Relational model terminologies and foundations • Some design concepts

  3. Introduction • Edgar F. Codd, 1970 • One sentence to explain relational database model: Data are organized in relations (tables), which are linked (relationship) by keys

  4. Relation • A relation is a two-dimensional table that has specific characteristics: • The table consist of rows and columns • Rows contain data about an entity instances • All values in a row describes the same entity instance • Columns contain data about attributes of the entity • All values in a column are of the same kind

  5. Relation (continued) • Relation’s specific characteristics go on: • Cells of the table hold a single value • Each row is distinct • Each column has a unique name • The order of the rows is unimportant • The order of the columns is unimportant

  6. Non-Relation Examples

  7. Relation Examples • And, any tables in page 92 and 93

  8. Relation Terminology Contrast

  9. Keys • A key is one or morecolumns of a relation that is used to identify a record • Primary key • Foreign key

  10. Primary Key • Primary key • The value of this key column uniquely identifies a single record (row) • There is only one primary key for a table • Candidate Key • A candidate to become the primary key • There can be multiple candidate keys for a table • Alternate key

  11. Composite Key • A key that contains two or more attributes (columns) • Example • “FirstName” + “LastName” • “FirstName” + “LastName” + “BirthDate” • “FirstName” + “LastName” + “BirthDate” + “BirthCity” • …

  12. Surrogate Key/Artificial Key • It’s a key created arbitrarily to replace the natural key • Typically used in place of a composite key • Usually it has no real meaning • Example • We can create a “ReviewID” in the “BookReviews” table to replace the original composite key

  13. Relationship and Foreign Key • Relationship defines how tables (relations) are linked • Two tables are linked by a pair of keys • The primary key of one table • The foreign key in the linked table • These two keys are of the same kind

  14. Relationship Example Foreign Key Primary Key (PK) Primary Key (PK)

  15. Relationship Types • One-to-one • Example: students and GSU network accounts • One-to-many • Example: students and diplomas • *Many-to-many • Example: students and professors

  16. Referential Integrity • Every value of a foreign key must match a value of the primary key • For example (“Premiere Products” database) • In “Customer” table, “RepNum” is a foreign key (linked to the “Rep” table where “RepNum” is the primary key). • Then every value of “RepNum” in the “Customer” table must exist in the “Rep” table

  17. Relational Algebra • Selection • Projection • Join • …

  18. Exercise • Define and enforce relationship for your “database assessment” tables

  19. Using MS Access • Exercise: using query designer (QBE) to query “AmazonBooks” • Choosing columns • Specifying criteria • Sorting • Calculating

  20. Summary • Understand three important concepts of relational database model • Relation • Keys • Primary key, candidate key, alternate key • Composite key • Natural key, surrogate key, artificial key • Foreign key • Relationship

  21. Good Resources • Edgar Frank Codd • http://www.db2tridex.org/efcodd.html • MS Access tutorial • http://mis.bus.sfu.ca/tutorials/MSAccess/tutorials.html

More Related