1 / 60

The Relational Model 1

CS 157 A Lecture 6 . The Relational Model 1. Prof. Sin-Min Lee Department of Mathematics and Computer Science. Prof. Sin-Min Lee Department of Computer Science. History of Relational Model. First proposed by a E.F. Codd in 1970. Codd proposed the Relational model in 1970.

imogene
Download Presentation

The Relational Model 1

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. CS 157 A Lecture 6 The Relational Model 1 Prof. Sin-Min Lee Department of Mathematics and Computer Science Prof. Sin-Min Lee Department of Computer Science

  2. History of Relational Model • First proposed by a E.F. Codd in 1970. Codd proposed the Relational model in 1970. • “ A relational model of data for large shared data banks.” • He linked the representation of data with that of mathematical sets. • First research started at IBM’s San Jose Research Laboratory. Prototype was called System R. • Commercial RDBMS’s started to appear in late 1970’s and early 1980’s. Most well known is Oracle.

  3. Dr. Edgar F. Codd (1923-2003) • Codd completed his PhD at the University of Michigan in 1963, and presented a thesis on the topic of a self-reproducing computer consisting of a large number of simple identical cells, each of which interacts in a uniform manner with its four immediate neighbors. Codd reported this work in a book entitled Cellular Automata published by Academic Press in 1968.

  4. Edgar Codd • The relational model devised by Codd was explored during the 1970s, and commercial relational database products began to emerge in the 1980s, originally for mainframe systems and later for microcomputers. Edgar Codd first wrote about the concept of relational databases in his paper "A Relational Model of Data for Large Shared Data Banks" in 1970. He was using the term "relation" in the strict mathematical sense of a table with a few special properties. Thus Codd was describing a system where all of the database - data, structure, rules - is housed in simple tables of rows and columns.

  5. Edgar Codd • While this may seem obvious to us today, it was by no means obvious in 1970. Codd went on to define relational databases more completely where he laid out twelve principles of relational databases in 1974. His most recent work in 1990, expands the list to 333 requirements.(Codd 90)Normalization for relational databases was introduced by Dr. E. F. Codd back in 1970 when he wrote his original paper. The concept has since been expounded upon by other experts in the field. • Read his obituary http://www.intosaiitaudit.org/intoit_articles/18p60top62.pdf

  6. Read: http://www.mercurynews.com/mld/mercurynews/news/local/5676133.htm?1c • IBM database developer dead at 79 • `RELATIONAL' MODEL IS BASIS OF TODAY'S TRANSACTIONSBy Lisa M. KriegerMercury News • Edgar F. Codd, an IBM computer pioneer who created the ``relational database model'' that underlies a $7 billion industry of storing the world's online business data, died of heart failure at home Friday in Williams Island, Fla. He was 79. • Bank accounts, credit cards, stock trading, travel reservations, online auctions and innumerable other now-routine data transactions all rely on Codd's model, based on highly abstract and complex mathematical theory. • Before Codd's landmark research paper in 1970, it was possible to store lots of information -- but analyzing it was difficult, requiring lines and lines of code for even simple tasks.

  7. Codd’s Original Paper • “A Relational Model of Data for Large Shared Data Banks” • Communications of the ACM, Volume 13, Number 6, June 1970 • Lower level (basement) of the new Martin Luther King, Jr. Library • Get to roll the shelves apart to access journals.

  8. Codd’s Reasons • Data independence from database implementation such as machine representation • Natural structure of data • Can be analyzed mathematically (Codd was a mathematician by training)

  9. Alternative: Network Model • Charles A. Bachman 1973 ACM Turing Award Lecture “The Programmer as Navigator” • Communications of the ACM, Volume 16, Number 11, November 1973, pp. 653-657

  10. INTRODUCTION The relational model is the most used data model for commercial data-processing because it is simple to use and to maintain. A relational data model is based on a collection of tables. The user of the database system may query these tables, insert new tuples, and update (modify) tuples. There are several languages for expressing these operations.

  11. Data Models • Codd suggests that any data model has three components: the data structures; the integrity constraints; the data manipulation operators.

  12. Relational Data Structure EMPLOYEE Emp# Name Emp Sex Mgr Emp# E1 Jones Male E65 E6 Smith Male E28 E28 Jones Female - Relation Attribute Heading Body Female Male Gender Domain

  13. Basic Structure The account table below represents a relation in the relational model. The three columns titles are the attributes and their domains. Each row is called a tuple. An account is a subset of the set of all possible tuples.

  14. The Domain Employee Emp# E1 E2 E3 Name Red Brown Black Mgr# - E1 E1 Attributes Person Name E1, E2, E3,E4 Red, Brown Black, Blue Domains Emp#

  15. Seven Characteristics of a relation • The name of the relation is different from all others. • Each cell of the relation contains only one value • Each attribute (or field) has a name that is distinct. • All the values of a particular attribute are from the same domain. • The order of the attributes makes no difference. • There are no duplicate tuples • The order of the tuples makes no difference.

  16. Example of the Student table. Primary Key

  17. Other terms... • Cardinality = Number of rows • Degree = Number of columns Degree = 5 Cardinality = 6

  18. Database Schema • Database Schema is the logical design of the database • Database instance is a snapshot of the data in the DB at a given instance in time • Relation instance is the programming language notion of a value of a variable

  19. Database Schema Relation schema consists of a list of attributes and their corresponding domain. As a convention, uppercase letter are used so Account-schema=(account-number, branch-name, balance) This means that account is a relation on Account-schema by account(Account-schema)

  20. Database Schema Relation instance is the set of values of a relation at a specific moment in time. This values may change in time causing a change in the relation as it is updated.

  21. The Relational Data Model • DATA STRUCTURES - domain, attribute, relation, tuple, primary key, degree, cardinality. • INTEGRITY CONSTRAINTS - entity integrity and referential integrity. • DATA MANIPULATION OPERATIONS - defined through relational algebra and equivalent relational calculus.

  22. Keys • Superkey is a set of one or more attributes that allow us to identify uniquely an entity in the entity set. • Candidate Key are minimal superkey in an entity, one of those keys is selected to be the primary key • Primary Key is a candidate key that is chosen to identify entities within an entity set • Foreign Key is a primary key of another relation schema

  23. Keys If K of R is a superkey for R, then the relation r(R) does not have two tuples with the same value. So if t1 and t2 are in r t1 = t2

  24. Find Candidate Keys R(A, B, C, D) • 2 3 4 • 1 1 3 4 • 2 1 4 • 4 1 2 3  X X {A, B} {A, C} {A, D} {B, C} {B, D} {C, D} X {A,C,D} {B, C, D}    X  = okay  = not okay

  25. How to determine keys • Strong entity set: the entity primary key becomes the relation primary key • Weak entity set: the primary key of the relation is the union of the strong entity set primary key and the discriminator • Relation set: the union of the primary keys of the related entity sets becomes a superkey of the relation

  26. How to determine keys • Combined tables: in a many-to-one, the primary key of the many becomes the relation primary key. In a one-to-one either primary key can be used • Multivalued attributes: the entity primary key becomes the primary key

  27. Schema Diagram A database schema with primary and foreign key dependencies primary relation shade indicates primary key account depositor customer dependency borrower branch loan

  28. Entity Integrity • No component of the Primary Key of a base relation is allowed to accept nulls. Surname Red Black Red Black Given Name John Fred Salary $40,000 $50,000 $60,000 $70,000

  29. Foreign Key • A foreign key is an attribute or attribute combination of one relation R2 whose values are required to match those of the primary key of relation R1 where R1 and R2 are not necessarily distinct. Note that a foreign key and the corresponding primary key should be defined on the same domain(s). Employee Dept Emp# e1 e2 e3 ename red blue brown Worksfordept d1 d2 Dept d1 d2 d3 Dname Pay Tax Art Foreign key

  30. Referential Integrity If base relation R2 includes a foreign key FK matching the primary key PK of some base relation R1 then every value of FK in R2 must either (a) be equal to the value of PK in some tuple of R1, or (b) be wholly null. Note that PK and FK may comprise more than one attribute and that R1 and R2 are not necessarily distinct. ( Stated more simply a foreign key should be a valid primary key value or null.)

  31. Foreign Key Rules For each foreign key three rules need to be answered: Can the foreign key accept nulls ? What should happen on an attempt to delete the target of a foreign key reference? What should happen on an attempt to update the target of a foreign key reference ? Employee Dept Dept d1 d2 d3 Dname Pay Tax Art Emp# e1 e2 e3 ename red blue brown Worksfordept d1 d2

More Related