Presentation is loading. Please wait.

# DBSQL 3-1 Copyright © Genetic Computer School 2009 Chapter 3 Relational Database Model.

## Presentation on theme: "DBSQL 3-1 Copyright © Genetic Computer School 2009 Chapter 3 Relational Database Model."— Presentation transcript:

DBSQL 3-1 Copyright © Genetic Computer School 2009 Chapter 3 Relational Database Model

DBSQL 3-2 Copyright © Genetic Computer School, Singapore 2009 Chapter 3 Overview Relational Database Relational Data Model Keys Relational Integrity Relational Algebra Tuple and Domain Relational Calculus

DBSQL 3-3 Copyright © Genetic Computer School, Singapore 2009 Relational Database Relational database those entities will then be represented by tables or shall we say relation. Each attribute in an entity will serve as the column of each relation which can be specified later with some keys and constraints.

DBSQL 3-4 Copyright © Genetic Computer School, Singapore 2009 Relational Data Model Relational Model is composed of tables and its relationship with other tables. Generally it follows the concept of tabular representation of an entity.

DBSQL 3-5 Copyright © Genetic Computer School, Singapore 2009 Cont’ Relation Tuple Domain Degree Cardinality Is a table with flat files of rows and columns which has certain properties Is a row of a relation and represents and instance of a relation Is the set of allowable values for one or more columns Is the number of attributes it contains Is the number of tuples it contains

DBSQL 3-6 Copyright © Genetic Computer School, Singapore 2009 Keys Every relation can be identified using a key column or field. These keys are in different types depending on the degree of a column definition and existence.

DBSQL 3-7 Copyright © Genetic Computer School, Singapore 2009 Type of Keys Primary Foreign Super Candidate Alternate It is a candidate key that uniquely identifies a relation It is an attribute key of a relation and also a unique key from another table. This key is used in order to link two tables together. It is a subset attribute of an entity that will uniquely identify a relation. Is any set of one or more columns whose combined values are unique among all occurrences (i.e., tuple or row). Alternate keys of any table are simply those candidate keys which are not currently selected as the primary key.

DBSQL 3-8 Copyright © Genetic Computer School, Singapore 2009 Relational Integrity Domain Type Key

DBSQL 3-9 Copyright © Genetic Computer School, Singapore 2009 Relational Algebra Relational Algebra is a theoretical way of manipulating data in a relational database. This is usually associated with querying the entire database system. It includes operations that act on existing table to produce new table, similar to the way of addition and subtraction act on numbers to produce new numbers.

DBSQL 3-10 Copyright © Genetic Computer School, Singapore 2009 Cont’

DBSQL 3-11 Copyright © Genetic Computer School, Singapore 2009 Cont’ Relational Algebra Relational Calculus It is more operational, and it deals with operational plan used in manipulating the database. It Lets user define what they want and how they want the data to be.

DBSQL 3-12 Copyright © Genetic Computer School, Singapore 2009 Relational Algebra Operations Set Operations Union Intersection Difference

DBSQL 3-13 Copyright © Genetic Computer School, Singapore 2009 Cont’ Operations that remove parts of a relation Selection Projection

DBSQL 3-14 Copyright © Genetic Computer School, Singapore 2009 Cont’ Operations that combine tuple from two relations Cartesian Product Join

DBSQL 3-15 Copyright © Genetic Computer School, Singapore 2009 Relational Algebra - Examples Selection R = Select ColumnName(condition) Relation Name

DBSQL 3-16 Copyright © Genetic Computer School, Singapore 2009 Cont’ Projection = Project = (ColumnName1, ColumnName2….ColumnNamen) Relation Name

DBSQL 3-17 Copyright © Genetic Computer School, Singapore 2009 Cont’ Cartesian Product The Cartesian product is defined by the concatenation of tuples between two relations. It is usually denoted by multiplication operation (R x S).

DBSQL 3-18 Copyright © Genetic Computer School, Singapore 2009 Cont’ Union This builds a relation consisting of all tuples appearing in either or both of two specified relations. The two relations must be union- compatible, which means that they must have the same number of attributes and these attributes must come from the same domain.

DBSQL 3-19 Copyright © Genetic Computer School, Singapore 2009 Cont’ Difference This operation builds a relation consisting of all tuples appearing the first but not the second of two specified relations.

DBSQL 3-20 Copyright © Genetic Computer School, Singapore 2009 Cont’ Intersection This builds a relation consisting of all tuples appearing in both of two specified relation. Again the two relations must be union- compatible.

DBSQL 3-21 Copyright © Genetic Computer School, Singapore 2009 Join Operations Join Operation Natural Join Theta Join Equi join Outer Join Full Outer Join Left-Outer Join Right- Outer Join

DBSQL 3-22 Copyright © Genetic Computer School, Singapore 2009 Advantages and Limitations of Relational Algebra Relational Algebra is useful specially in query optimization but there are areas in which it cannot be applied Relational Algebra cannot modify a database Relational Algebra cannot perform arithmetic operations

DBSQL 3-23 Copyright © Genetic Computer School, Singapore 2009 Tuple and Domain Relational Calculus Tuple Relational Calculus It is a form of relational calculus where it tries to find a predicate only if it is true. The common term given to this form is called tuple variable. Notation {E | L (E)}

DBSQL 3-24 Copyright © Genetic Computer School, Singapore 2009 Cont’ Domain Relational Calculus Domain relational Calculus uses variables that take values from domains instead of a relation’s tuple. If a domain formulae is composed of atoms F(d1, d2, …, d n) then it can be represented by the variable: {d1, d2, …, d n | F (d1, d2, …, d n) }

DBSQL 3-25 Copyright © Genetic Computer School, Singapore 2009 End

Download ppt "DBSQL 3-1 Copyright © Genetic Computer School 2009 Chapter 3 Relational Database Model."

Similar presentations

Ads by Google