Relational Model: History

Similar documents
Databases 1. Daniel POP

ER to Relational Mapping

Chapter 9: Relational DB Design byer/eer to Relational Mapping Relational Database Design Using ER-to- Relational Mapping Mapping EER Model

Relational Databases

Relational Model, Relational Algebra, and SQL

CMP-3440 Database Systems

Database Management System 9

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity

Review for Exam 1 CS474 (Norton)

Database Management

Relational Model and Relational Algebra. Rose-Hulman Institute of Technology Curt Clifton

ER-to-Relational Mapping

THE RELATIONAL DATABASE MODEL

Chapter 2: Entity-Relationship Model

Chapter 3B Objectives. Relational Set Operators. Relational Set Operators. Relational Algebra Operations

Relational DB Design by ER- and EER-to-Relational Mapping Design & Analysis of Database Systems

CS 377 Database Systems

Topic 5: Mapping of EER Diagrams to Relations

RELATIONAL DATA MODEL

Ian Kenny. November 28, 2017

Data about data is database Select correct option: True False Partially True None of the Above

Relational Algebra. Procedural language Six basic operators

Relational Model History. COSC 304 Introduction to Database Systems. Relational Model and Algebra. Relational Model Definitions.

Chapter 3. The Relational Model. Database Systems p. 61/569

RELATIONAL DATA MODEL: Relational Algebra

Review -Chapter 4. Review -Chapter 5

1. Considering functional dependency, one in which removal from some attributes must affect dependency is called

Introduction to Data Management CSE 344. Lectures 8: Relational Algebra

Mahathma Gandhi University

Basant Group of Institution

B.H.GARDI COLLEGE OF MASTER OF COMPUTER APPLICATION. Ch. 1 :- Introduction Database Management System - 1

Databases Relational algebra Lectures for mathematics students

Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 6 Outline. Unary Relational Operations: SELECT and

CIS 330: Applied Database Systems. ER to Relational Relational Algebra

CS317 File and Database Systems

Chapter 6 The Relational Algebra and Calculus

Introduction to Query Processing and Query Optimization Techniques. Copyright 2011 Ramez Elmasri and Shamkant Navathe

Relational Algebra and SQL

Chapter 3: The Relational Database Model

COSC344 Database Theory and Applications. σ a= c (P) S. Lecture 4 Relational algebra. π A, P X Q. COSC344 Lecture 4 1

Relational Algebra. Relational Algebra. 7/4/2017 Md. Golam Moazzam, Dept. of CSE, JU

Introduction to Data Management CSE 344. Lectures 8: Relational Algebra

II B.Sc(IT) [ BATCH] IV SEMESTER CORE: RELATIONAL DATABASE MANAGEMENT SYSTEM - 412A Multiple Choice Questions.

Relational model continued. Understanding how to use the relational model. Summary of board example: with Copies as weak entity

Unit I. By Prof.Sushila Aghav MIT

Chapter 3: Relational Model

Relational Database Systems Part 01. Karine Reis Ferreira

8) A top-to-bottom relationship among the items in a database is established by a

2.2.2.Relational Database concept

Chapter 6: Entity-Relationship Model. The Next Step: Designing DB Schema. Identifying Entities and their Attributes. The E-R Model.

Chapter 6: RELATIONAL DATA MODEL AND RELATIONAL ALGEBRA

Relational Database: The Relational Data Model; Operations on Database Relations

Ch 9: Mapping EER to Relational. Follow a seven-step algorithm to convert the basic ER model constructs into relations steps 1-7

Rajiv GandhiCollegeof Engineering& Technology, Kirumampakkam.Page 1 of 10

Fundamentals, Design, and Implementation, 9/e Copyright 2004 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M.

The Next Step: Designing DB Schema. Chapter 6: Entity-Relationship Model. The E-R Model. Identifying Entities and their Attributes.

; Spring 2008 Prof. Sang-goo Lee (14:30pm: Mon & Wed: Room ) ADVANCED DATABASES

Chapter 6: Entity-Relationship Model

Why Study the Relational Model? The Relational Model. Relational Database: Definitions. The SQL Query Language. Relational Query Languages

Chapter 6: Entity-Relationship Model

Relational Query Languages. Preliminaries. Formal Relational Query Languages. Example Schema, with table contents. Relational Algebra

Relational Database Model. III. Introduction to the Relational Database Model. Relational Database Model. Relational Terminology.

Database Technology Introduction. Heiko Paulheim

Relational Algebra. Mr. Prasad Sawant. MACS College. Mr.Prasad Sawant MACS College Pune

CS34800 Information Systems. The Relational Model Prof. Walid Aref 29 August, 2016

Chapter 9 Outline. Relational Database Design by ER and EERto-Relational. Mapping Fundamentals of Database Systems

Chapter 13: Query Processing

4. Entity Relationship Model

Unit 2. Unit 3. Unit 4

Outline. Note 1. CSIE30600 Database Systems ER/EER to Relational Mapping 2

Chapter 7: Entity-Relationship Model

v Conceptual Design: ER model v Logical Design: ER to relational model v Querying and manipulating data

Chapter 7 Relational Database Design by ER- and EERR-to-Relational Mapping

Relational Algebra. Note: Slides are posted on the class website, protected by a password written on the board

Chapter 7: Entity-Relationship Model

Chapter 7: Entity-Relationship Model

Lecture Query evaluation. Combining operators. Logical query optimization. By Marina Barsky Winter 2016, University of Toronto

Chapter 2: Intro to Relational Model

Comp 5311 Database Management Systems. 2. Relational Model and Algebra

! A relational algebra expression may have many equivalent. ! Cost is generally measured as total elapsed time for

Chapter 13: Query Processing Basic Steps in Query Processing

A database can be modeled as: + a collection of entities, + a set of relationships among entities.

Algorithms for Query Processing and Optimization. 0. Introduction to Query Processing (1)

1. Introduction; Selection, Projection. 2. Cartesian Product, Join. 5. Formal Definitions, A Bit of Theory

Chapter 17. Methodology Logical Database Design for the Relational Model

- Database: Shared collection of logically related data and a description of it, designed to meet the information needs of an organization.

Chapter 6 5/2/2008. Chapter Outline. Database State for COMPANY. The Relational Algebra and Calculus

Databases - Relational Algebra. (GF Royle, N Spadaccini ) Databases - Relational Algebra 1 / 24

This lecture. Projection. Relational Algebra. Suppose we have a relation


Chapter 12: Query Processing

Join (SQL) - Wikipedia, the free encyclopedia

The Relational Model

Chapter 5 Relational Algebra. Nguyen Thi Ai Thao

Database Management System 6 ER Modeling...

Relational Model. Rab Nawaz Jadoon DCS. Assistant Professor. Department of Computer Science. COMSATS IIT, Abbottabad Pakistan

QUERY PROCESSING & OPTIMIZATION CHAPTER 19 (6/E) CHAPTER 15 (5/E)

Databases Lectures 1 and 2

Chapter 6: Formal Relational Query Languages

Conceptual (high-level, semantic)/ Physical (low-level, internal)/ Implementation (representational)

Transcription:

Relational Model: History Objectives of Relational Model: 1. Promote high degree of data independence 2. Eliminate redundancy, consistency, etc. problems 3. Enable proliferation of non-procedural DML s Relational Model History 1. System R Late 70 s, IBM Descendents: SQL, DB2, Oracle 2. Interactive Graphics Retrieval System (INGRES) Berkeley Descendents: INGRES 3. Peterlee Relational Test Vehicle IBB (UK) Components Structural part Integrity rules DML Procedural language Returns sets of records Consists of 5 basic operations Relational Model: Formal Query Language - Relational Algebra Arguments to operators are relations, and operators produce relations as results I.e., relations are closed under the relational algebra Allows nesting of operators Operators: 1. Select Operator: σ Cardinality: unary Syntax: σ p (relational expression) Semantics: Returns those tuples in argument relational expression that meet the conditions specified by predicate p p specified in terms of Boolean operators, column names, and values 1

2. Project Operator: π Cardinality: unary Syntax: π attribute list (relational expression) Semantics: Returns a subtuple for each tuple in argument r, using only the columns specified in attribute list 3. Cartesian product Operator: Syntax: r s Semantics: Resulting tuples generated by pairing every tuple in argument r with every tuple in argument s r s {< a 1,..., a m, b 1,..., b n > < a 1,..., a m > r < b 1,..., b n > s} If R has m columns and S has n columns, r(r) s(s) has m + n columns If r has i rows and s has j rows, r s has i j rows Columns labeled using Schema name.column name Rarely used in isolation Usually only the resulting rows that represent info re the same entity are retained, via a selection operation Operation in which two or more related tables are combined and only the rows pertaining to a single entity are retained is called a join 2

4. Union Operator: Syntax: r s Semantics: Standard set union operation of arguments r(r) and s(s) In order to perform union, arguments must be union compatible: (a) arity(r) = arity(s) (b) If R(A 1, A 2,..., A n ) and S(B 1, B 2,..., B n ) then, domain(a i ) domain(b i ), 1 i n 5. Set difference Operator: Syntax: r s Semantics: Standard set difference operation of arguments r and s r and s must be union compatible Relational Model: Formal Query Language - Relational Algebra Extensions The original language has been extended to facilitate queries that would otherwise be complex Extended relational algebra operations: 1. Assignment Operator: Syntax: variable relational expression Semantics: Standard variable assignment Allows temporary storage of intermediate results 3

2. Renaming columns Syntax: variable(a 1, A 2,..., A n ) relational expression Arity of relational expression must be n Semantics: Assigning alias to a column name Simplifies some queries, especially recursive ones 3. Renaming relations (on-the-fly) Syntax: ρ rel name (relational expression) 4. Theta join Operator: θ Syntax: r θ s Semantics: Equivalent to a cartesion product of its arguments followed by a selection based on the specified predicate Given r(r) and s(s), r θ s σ θ (r s)) Result has a column for each schema column of argument r and argument s 5. Equijoin Same as theta join except predicate restricted to equality test on columns 4

6. Natural join Operator: Syntax: r s Semantics: Equivalent to an equijoin except that no predicate is specified Given r(r), s(s), T = R S, I = R S r s π T (σ r.a1=s.a 1,r.a 2=s.a 2,...,r.a n=s.a n (r s)), where a i I Equivalency based on columns in schemas of arguments r and s that have the same name Only rows that have the same values for these same-named columns will be retained The result will only have one copy of the same-named columns 7. Semijoin Operator: p or p Syntax: r p s Semantics: Returns those tuples in r that would participate in a join with s Given r(r), s(s), r p s π R (σ p (r s)) 5

8. Division Operator: Syntax: r s Semantics: Given r(r), s(s), S R, T = R S (i.e., T are those columns that appear in R but not in S) Then (a) r s t will consist of columns T (b) There will be one tuple in the result for each tuple in r that is paired with every set of values for R that appear in relation s r s t where t computed as (a) t 1 = π T (r) (b) t 2 = π T ((t 1 s) r) (c) t = t 1 t 2 Relational Model: Formal Query Language - Relational Algebra Enhancements The original language has also been extended to facilitate queries that would otherwise be impossible Relational algebra enhancements: 1. Aggregate functions Operator: gf f, where g is a list of attribute names f is a list of function-attribute name pairs Cardinality: unary Syntax: gf f (r) Semantics: Function f is applied to columns c in argument r Functions in f are range functions They perform a calculation on a range of values (Max, Avg,...) Each function in f is applied to all tuples in r Each function is applied only to the attribute it is paired with The resulting relation will have one column for each function May include optional grouping attributes g If g appears, then tuples in r are grouped in terms of the unique attribute values for each attribute occurring in g, on an attribute-by-attribute basis The functions in f are then applied to each group of tuples The result will contain 1 tuple for each group 6

2. Outer joins Operator: (left outer join), (right outer join), (full outer join) Syntax: r s, etc. Semantics: Same as a theta join, except: Includes those tuples in argument r that have no match in argument s, with unmatched fields of r padded with NULL (Right and full outer joins similar) 3. Outer union Operator: (Note: No formal symbol for this) Syntax: r s Semantics: Let r(r), s(s), U = R S, and R S φ R S must contain keys of R and S Then u(u) = r s, generated as If t i r has same key value as u j s, generate new tuple in u with attributes of t i and u j For tuples in r and s that do not meet above requirement, include a tuple for each with attributes from other relation padded with NULL Allows union of non-union compatible relations 7

4. Recursive closure Applicable to recursive relations Apply a relation recursively to the results of its application Only achieved using recursion in a host programming language Foundational Rules Relational Model: Codd s Rules of Relational DBMSs Rule 0: Foundational rule For any system that is advertised as, or claimed to be, a relational DBMS, that system must be able to manage DB s entirely through its relational capabilities. Rule 12: Nonsubversion rule If a relational system has a low-level (record-at-a-time) language, that low-level language cannot be used to subvert or bypass the integrity rules and constraints expressed in the higher-level (setat-a-time) relational language. Structural Rules Rule 1: Information representation All information in a relational DB is represented explicitly at the logical level and in exactly one way by values in tables. Rule 6: View update All views that are theoretically updatable are also updatable by the system. Integrity rules Rule 3: Systematic treatment of NULLs NULL values are supported for representing missing information and inapplicable information in a systematic way, independent of data type. Rule 10: Integrity independence Integrity constraints specific to a particular relational DB must be definable in the relational DB sublanguage and storable in the catalog, not in application programs. Data Manipulation Rules Rule 2: Guaranteed access Each and every datum in a relational DB is guaranteed to be logically accessible by resorting to a combination of table name, primary key value, and column name. Rule 4: Dynamic online catalog based on relational model The DB description is represented at the logical level in the same way as ordinary data, so that authorized users can apply the same relational language to its interrogation as they apply to the regular data. Rule 5: Comprehensive data language A relational system may support several languages and various modes of terminal use. However, there must be at least one language whose statements can express all of the following items. data definition view definition data manipulation integrity constraints authorization transaction boundaries Rule 7: High-level insert, update, delete The capability of handling a base relation or derived relation as a single operand applies not only to the retrieval of data but also to the insertion, update, and deletion of data. Data Independence Rules Rule 8: Physical data independence Application programs and terminal activities remain logically unimpaired whenever any changes are made in either storage representations or access methods. Rule 9: Logical data independence Application programs and terminal activities remain logically unimpaired whenever information-preserving changes of any kind that theoretically permit unimpairment are made to the base tables. 8

Rule 11: Distribution independence The data manipulation sublanguage of a relational DBMS must enable application programs and inquiries to remain logically the same whether data are physically centralized or distributed. 1. Mapping regular (strong) ETs Create a table for each regular ET Columns represent attributes If attribute composite, include only leaves Do not include multivalued attributes (see later) 2. Mapping weak ETs Create a table for each weak ET Proceed as for strong ETs Relational Model: ER to RM Mapping Include columns for key attributes of parent ET (becomes foreign key) Table key is union of parent key and discriminator 3. Mapping 1:1 binary relations (a) Foreign key approach Preferred method Identify ET that has total participation Include columns for key attributes of the other ET (becomes foreign key) Include columns for any attributes of the relation type itself If neither ET has total participation Do as above Note that result will include NULL (foreign key attributes) for some tuples Could include key attributes of each ET in the other Compounds redundancy problem (b) Merged relation approach Most relevant if both ETs participate totally Combine 2 ETs into single table Include columns for any attributes of the relation type itself Table key is key of either participant (c) Cross reference (relationship relation) approach Create table consisting of i. Key attributes of each participant (become foreign keys) ii. Attributes of the relation type itself Table key is key of either participant, providing no NULL values Also referred to as a lookup table 4. Mapping 1:N binary relations Include columns for key attributes of the unary ET in the table of the n-ary participant (becomes foreign key) Include columns for any attributes of the relation type itself Alternative is cross reference approach as described in 1:1 case 9

5. Mapping N:M binary relations Create a table consisting of (a) Key attributes of each participant (become foreign keys) (b) Attributes of the relation type itself Table key is union of participant keys 6. Mapping multivalued attributes Create a table consisting of (a) Key attributes of the parent ET (becomes foreign key) (b) The multivalued attribute Table key is entire set of attributes 7. Mapping n-ary relations Handle as for binary N:M relation types Table key is generally union of keys of participants The key of any unary participant does not become part of key of new relation 8. Mapping specialization/generalization (a) Multiple relations: super- and sub- classes approach Create tables for the superclass and for each subclass Include in each subclass relation the key of the superclass (becomes foreign key) Table key of subclass is key of superclass Most general approach - works for all types of constraints (b) Multiple relations: subclasses only approach Create tables for each subclass Attributes of each child are the union of its attributes and the parent s attributes Table key of subclass is key of superclass Applicable only if superclass participates totally If not, superclass entities that are not members of subclass will be lost For overlapping subclasses, will duplicate info No relation holds all of the superclass entities Would need to perform outer union or full outer join to recover 10

(c) Single relation: 1 type attribute approach Create a table consisting of i. Attributes of each subclass ii. Attributes of the the superclass iii. A new type attribute (discriminator) Value of discriminator indicates which subclass an entity belongs to If specialization is attribute-defined, do not include Defining attribute value can be used for discrimination Attributes of each child are the union of its attributes and the parent s attributes Table key is key of superclass Applicable only if disjoint specialization Results in NULL values for subclass-specific attributes to which entity does not belong Preferred approach if few attributes associated with each subclass (d) Single relation: multiple type attributes approach Create a table as for single relation: 1 type attribute above Include one type attribute for each subclass Discriminators are Boolean Most applicable for overlapping specialization (but works for disjoint) 9. Mapping unions Create a table for the union type Key handled in one of following ways: (a) If all categories have same key Include key in union table (b) If all categories have different keys Include a new surrogate key attribute in union type Is artificial attribute whose value is guaranteed to be unique Include surrogate key in each category as well Key will be NULL for category entities that do not participate in union 11