13
Foundations of Relational Implementation Defining Relational Data Relational Data Manipulation Relational Algebra

Foundations of Relational Implementation n Defining Relational Data n Relational Data Manipulation n Relational Algebra

Embed Size (px)

Citation preview

Page 1: Foundations of Relational Implementation n Defining Relational Data n Relational Data Manipulation n Relational Algebra

Foundations of Relational Implementation Defining Relational Data Relational Data Manipulation Relational Algebra

Page 2: Foundations of Relational Implementation n Defining Relational Data n Relational Data Manipulation n Relational Algebra

Defining Relational Data

Review of Terminology– Fig. 9-2

Implementing a Relational Database– Data Definition Language (DDL) used to

describe the database structure, i.e., names the tables in the database, the columns of those tables, defines indexes, and describes other structures such as constraints and security restrictions.Fig.9-3

Page 3: Foundations of Relational Implementation n Defining Relational Data n Relational Data Manipulation n Relational Algebra

Relational Data Manipulation

Categories of Relational Data Manipulation Language (DML)

DML Interfaces to the DBMS

Page 4: Foundations of Relational Implementation n Defining Relational Data n Relational Data Manipulation n Relational Algebra

Categories of Relational Data Manipulation Language (DML) Relational Algebra

– Procedural processing that uses operators such as +,-, that work on relations.

– Infrequently used in commercial database processing.

Relational Calculus– Nonprocedural processing that uses predicate

calculus logic.– Not used in commercial database processing.

Page 5: Foundations of Relational Implementation n Defining Relational Data n Relational Data Manipulation n Relational Algebra

Categories of Relational Data Manipulation Language (DML) Transform-Oriented Languages

– Nonprocedural languages that transform input relational data as results showed in a single relation.

– Examples are: SQUARE, SEQUEL and SQL.

Page 6: Foundations of Relational Implementation n Defining Relational Data n Relational Data Manipulation n Relational Algebra

Categories of Relational Data Manipulation Language (DML) Query-by-Example (QBE) and Query-

by-Form– With a graphical interface the user is

presented a materialization of one or more relations. The DBMS constructs queries (in SQL) on behalf of the user.

Page 7: Foundations of Relational Implementation n Defining Relational Data n Relational Data Manipulation n Relational Algebra

DML Interfaces to the DBMS

Data Manipulation by Means of Forms ->Fig. 9-7,8

Query/Update Language Interface -> Fig. 9-9

Stored Procedure Interface Application Program Interface

-> Fig. 9-10

Page 8: Foundations of Relational Implementation n Defining Relational Data n Relational Data Manipulation n Relational Algebra

Relational Algebra

Relational Operators Expressing Queries in Relational

Algebra

Page 9: Foundations of Relational Implementation n Defining Relational Data n Relational Data Manipulation n Relational Algebra

Relational Operators

Union– Adding the tuples of an relation to those of

a second relation to produce a third relation. A + B

– Relation must be union compatible, i.e., each relation must have the same number of attributes and corresponding attributes must have the same domain

– Fig. 9-10,11,12

Page 10: Foundations of Relational Implementation n Defining Relational Data n Relational Data Manipulation n Relational Algebra

Relational Operators

Difference– A - B creates a third relation that contains

tuples that occur in the first relation but not in the second.

– Fig. 9-13 Intersection

– Creates a relation containing the tuples that appear in both the first and second relation -> Fig. 9-14

Page 11: Foundations of Relational Implementation n Defining Relational Data n Relational Data Manipulation n Relational Algebra

Relational Operators

Product– A * B is the concatenation of every tuple of one

relation with every tuple of a second relation. (Note: some meaningless tuples are included in the resulting relation) -> Fig. 9-15,16

Projection– Selects specified attributes from one relation

e.g. STUDENT[Age, GradeLevel] -> Fig. 9-15,17

Page 12: Foundations of Relational Implementation n Defining Relational Data n Relational Data Manipulation n Relational Algebra

Relational Operators

Selection– Takes a horizontal subset (rows) of a relation

e.g. STUDENT WHERE Major = ‘Math’ -> Fig. 9-18

Join– A combination of the product, selection, and

projection operations.– Equi-join Vs. natural join – Fig. 9-19

Page 13: Foundations of Relational Implementation n Defining Relational Data n Relational Data Manipulation n Relational Algebra

Expressing Queries in Relational Algebra Fig. 9-20 Examples pg. 231-234 and fig. 9-21