Chapter 2: Relational Model

Slides:



Advertisements
Similar presentations
Chapter 3 : Relational Model
Advertisements

Ver 1,12/09/2012Kode :CCs 111,sistem basisdataFASILKOM Chapter 2: Relational Model Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan.
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
Chapter 3: Relational Model
Relational Database Management System A type of database in which records are stored in relational form is called relational database management system.
Database Architecture The Relational Database Model.
Relational Model & Relational Algebra. 2 Relational Model u Terminology of relational model. u How tables are used to represent data. u Connection between.
Lecture 2 The Relational Model. Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations.
Chapter 4 The Relational Model Pearson Education © 2014.
Relational Model Session 6 Course Name: Database System Year : 2012.
Content Resource- Elamsari and Navathe, Fundamentals of Database Management systems.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Intro to Relational.
DBSQL 3-1 Copyright © Genetic Computer School 2009 Chapter 3 Relational Database Model.
Database System Concepts, 5 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Relational.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Intro to Relational.
Chapter 2 Adapted from Silberschatz, et al. CHECK SLIDE 16.
ICOM 5016 – Introduction to Database Systems Lecture 5b Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
1 The Relational Database Model. 2 Learning Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical.
Databases. Not All Tables Are Created Equal Spreadsheets use tables to store data and formulas associated with that data The “meaning” of data is implicit.
9/7/2012ISC329 Isabelle Bichindaritz1 The Relational Database Model.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com ICOM 5016 – Introduction.
11/07/2003Akbar Mokhtarani (LBNL)1 Normalization of Relational Tables Akbar Mokhtarani LBNL (HENPC group) November 7, 2003.
CSc340 1b1 The Relational Model Chapter 2 Database Schema Keys Schema Diagrams Relational Query Languages Relational Operations.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Intro to Relational.
2.1 Chapter 2: Relational Model. 2.2 Chapter 2: Relational Model Structure of Relational Databases Fundamental Relational-Algebra-Operations Additional.
Chapter 2 Introduction to Relational Model. Example of a Relation attributes (or columns) tuples (or rows) Introduction to Relational Model 2.
Chapter 2: Intro to Relational Model. 2.2 Example of a Relation attributes (or columns) tuples (or rows)
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Introduction.
Chapter 3: Relational Model  Structure of Relational Databases  Normal forms (chap. 7)  Reduction of an E-R Schema to Relational (Sect. 2.9)  Relational.
CHAPTER 2 : RELATIONAL DATA MODEL Prepared by : nbs.
The Relational Model © Pearson Education Limited 1995, 2005 Bayu Adhi Tama, M.T.I.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Intro to Relational.
Chapter 3 The Relational Model. Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between mathematical.
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Intro to Relational.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts - 6 th Edition Chapter 8: Relational Algebra.
COP Introduction to Database Structures
Module 2: Intro to Relational Model
Databases Chapter 16.
Introduction to Relational Model
Relational Model By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany)
RELATION.
Chapter 2: Intro to Relational Model
Lecture 2 The Relational Model
Chapter 3: Intro to Relational Model
Chapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model
Chapter 3 The Relational Database Model
Data Base System Lecture 6: Relational Model
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
The Relational Model Transparencies
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 2: Intro to Relational Model
Chapter 4 The Relational Model Pearson Education © 2009.
Getting to First Base: Introduction to Database Concepts
Chapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model
Example of a Relation attributes (or columns) tuples (or rows)
Design tools and techniques for a relational database system
Chapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model
Getting to First Base: Introduction to Database Concepts
Chapter 4 The Relational Model Pearson Education © 2009.
Database Dr. Roueida Mohammed.
Database Systems: Design, Implementation, and Management
Lecture 2 Relational Database
Presentation transcript:

Chapter 2: Relational Model Information Technology Department Bryar Hassan (MSc Eng.) Bryar.hassan@kissr.edu.krd

Structure of Relational Database A relational database consists of a collection of tables Relation: it is used to refer to a table in relational model Tuple: it is used to refer to a row Attribute: it is used to a column of a table Relation Instance: it refers to a specific instance of a relation. e.g., containing a specific set of rows Database System Concepts

Example of Relation Database System Concepts

Attribute Types The set of allowed values for each attribute is called the domain of the attribute Attribute values are (normally) required to be atomic; that is, indivisible The special value null is a member of every domain The null value causes complications in the definition of many operations Database System Concepts

Keys We must have a way to specify how tuples within a given relation are distinguished. This is expressed in terms of their attributes. The values of the attribute values of a tuple must be such that they can uniquely identify the tuple. No two tuples in a relation are allowed to have exactly the same value for all attributes. A key (whether primary, candidate, or super) is a property of the entire relation, rather than of the individual tuples Super key: is a set of one or more attributes that, taken collectively, allow us to identify uniquely a tuple in the relation. Candidate key: If K is a superkey, then so is any superset of K. We are often interested in superkeys for which no proper subset is a superkey. Such minimal superkeys are called candidate keys Database System Concepts

Keys Primary key: is a candidate key that is chosen by the database designer as the principal means of identifying tuples within a relation Foreign key: A relation, say r1, may include among its attributes the primary key of another relation, say r2. This attribute is called a foreign key from r1, referencing r2. The relation r1 is also called the referencing relation of the foreign key dependency, and r2 is called the referenced relation of the foreign key Database System Concepts

Primary Key Versus Foreign Key A table can only have one primary key. A primary key is a field or set of fields that: Has a unique value for each record Is indexed Identifies the record You can add the primary key from one table to another table to create a relationship between them. In the other table, it is called a foreign key. Database System Concepts

Primary Key Versus Foreign Key A foreign key, simply stated, is another table's primary key. The values in a foreign key field match values in the primary key, indicating that the two records are related For example, a customer and an order that she has placed. Unlike primary keys: A table can have more than one foreign key. A foreign key does not necessarily have unique values. A foreign key cannot reliably identify a particular record. For example, you cannot always tell which record you are viewing from the Orders table by looking at the Customer ID. Database System Concepts

Example Suppose you use the primary key of the Customers table in the Orders table. In the Orders table it is a foreign key. Primary key Foreign key Database System Concepts

Database Schema Database schema: it is the logical design of the database Example of the schema diagram for University database Database System Concepts

Relational Algebra The relational algebra defines a set of operations on relations, paralleling the usual algebraic operations such as addition, subtraction or multiplication, which operate on numbers. Just as algebraic operations on numbers take one or more numbers as input and return a number as output, the relational algebra operations typically take one or two relations as input and return a relation as output. Database System Concepts

Selection of Tuples Database System Concepts

Selection of Columns (Attributes) Database System Concepts

Joining Two Relations – Cartesian Product Database System Concepts

Union of Two Relations Database System Concepts

Set Different of Two Relations Database System Concepts

Set Intersection of Two Relations Database System Concepts

Joining Two Relations – Natural Join Let r and s be relations on schemas R and S respectively. Then, the “natural join” of relations R and S is a relation on schema R  S obtained as follows: Consider each pair of tuples tr from r and ts from s. If tr and ts have the same value on each of the attributes in R  S, add a tuple t to the result, where t has the same value as tr on r t has the same value as ts on s Database System Concepts

Natural Join Example Database System Concepts

Summary of Relational Algebra Database System Concepts

Summary Structure of Relational Database Attribute Types Keys Primary Key Versus Foreign Key Database Schema Relational Aljebra Database System Concepts