Web Science & Technologies University of Koblenz ▪ Landau, Germany Relational Data Model.

Slides:



Advertisements
Similar presentations
Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Relational Data Model continued Steffen Staab with Simon.
Advertisements

Information Systems & Semantic Web University of Koblenz Landau, Germany Advanced Data Modeling Steffen Staab with Simon Schenk TexPoint fonts used in.
COMP 5138 Relational Database Management Systems Semester 2, 2007 Lecture 5A Relational Algebra.
IS698: Database Management Min Song IS NJIT. The Relational Data Model.
Relational Model Table = relation. Column headers = attributes. Row = tuple Beers Relation schema = name(attributes) + other structure info., e.g., keys,
Chapter 3 : Relational Model
Ver 1,12/09/2012Kode :CCs 111,sistem basisdataFASILKOM Chapter 2: Relational Model Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 52 Database Systems I Relational Algebra.
Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
Relational Model and Relational Algebra Rose-Hulman Institute of Technology Curt Clifton.
1 Minggu 2, Pertemuan 3 The Relational Model Matakuliah: T0206-Sistem Basisdata Tahun: 2005 Versi: 1.0/0.0.
CS405G: Introduction to Database Systems Final Review.
Relational Algebra.
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.
1 The Relational Data Model, Relational Constraints, and The Relational Algebra.
Chapter 4 The Relational Model.
Database Management COP4540, SCS, FIU Relational Model Chapter 7.
DBSQL 3-1 Copyright © Genetic Computer School 2009 Chapter 3 Relational Database Model.
Chapter 3 The Relational Model. 2 Chapter 3 - Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between.
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.
CIS552Relational Model1 Structure of Relational Database Relational Algebra Extended Relational-Algebra-Operations Modification of the Database.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com ICOM 5016 – Introduction.
Relational Algebra (Chapter 7)
FEN Introduction to the database field:  The Relational Model Seminar: Introduction to relational databases.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Intro to Relational.
Computing & Information Sciences Kansas State University Friday, 26 Jan 2008CIS 560: Database System Concepts Lecture 2 of 42 Friday, 29 August 2008 William.
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.
©Silberschatz, Korth and Sudarshan3.1Database System Concepts Chapter 3: Relational Model Structure of Relational Databases Relational Algebra Extended.
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.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Module A: Formal Relational.
CMPT 258 Database Systems Relational Algebra (Chapter 4)
The Relational Model. 2 Relational Model Terminology u A relation is a table with columns and rows. –Only applies to logical structure of the database,
Jennifer Widom Relational Databases The Relational Model.
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.
Chapter 4 The Relational Model Pearson Education © 2009.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts - 6 th Edition Chapter 8: Relational Algebra.
Module 2: Intro to Relational Model
Introduction to Relational Model
Chapter 2: Relational Model
Chapter 2: Intro to Relational Model
Chapter 6: Formal Relational Query Languages
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
Relational Databases The Relational Model.
Relational Databases The Relational Model.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 2: Intro to Relational Model
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model
Chapter 6: Formal Relational Query Languages
Example of a Relation attributes (or columns) tuples (or rows)
Chapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model
Chapter 4 The Relational Model Pearson Education © 2009.
Relational Model B.Ramamurthy 5/28/2019 B.Ramamurthy.
Lecture 2 Relational Database
Presentation transcript:

Web Science & Technologies University of Koblenz ▪ Landau, Germany Relational Data Model

Steffen Staab Advanced Data Modeling 2 of 48 WeST Overview  Relational data model;  Tuples and relations;  Schemas and instances;  Named vs. unnamed perspective;  Relational algebra;

Steffen Staab Advanced Data Modeling 3 of 48 WeST Table PlayerBirth Year Andy1980 Wim1975 Liam1985 Mike1988 Bert1971

Steffen Staab Advanced Data Modeling 4 of 48 WeST Observations  The rows of the table contain pairs occurring in the relation player.  There are two columns, labeled respectively by “name” and “birth year”.  The values in each column belong to different domains of possible values.

Steffen Staab Advanced Data Modeling 5 of 48 WeST How to specify a relation 1.specifying the names of the columns (also called fields or attributes); 2. specifying a domain of possible values for each column; 3. enumerate all tuples in the relation. (1)–(2) refer to the schema of this relation, while (3) to an instance.

Steffen Staab Advanced Data Modeling 6 of 48 WeST Domains and attributes  A set of domains (sets of values);  A set of corresponding domain names d 1, d 2, …  A set of attributes a 1, a 2, …

Steffen Staab Advanced Data Modeling 7 of 48 WeST Relation Schema and Instances Tuple: any finite sequence (v 1, …, v n ). n is the arity of this tuple. Relation schema: r(a 1 :d 1, …, a n :d n ) where n ¸ 0, r is a relation name, a 1, …, a n are distinct attributes, d 1, …, d n are domain names. Relation instance: finite set of tuples (v 1, …, v n ) of arity n such that v i 2 D i for all i.

Steffen Staab Advanced Data Modeling 8 of 48 WeST Observation 1.The attributes in each column must be unique. 2. A relation is a set. Therefore, when we represent a relation by a table, the order of rows in the table does not matter. Let us add to this: 3. The order of attributes does not matter.

Steffen Staab Advanced Data Modeling 9 of 48 WeST New notation for tuples  A tuple is a set of pairs { (a 1, v 1 ), …, (a n, v n ) } denoted by { a 1 =v 1, …, a n =v n },  Let d 1, …, d n be domain names and be the corresponding domains.  The tuple conforms to a relation schema r(a 1 :d1, …, a n :d n ) if v i 2 D i for all i.

Steffen Staab Advanced Data Modeling 10 of 48 WeST Relational data are structured Note that in the relational data model tuples stored in a table are structured:  all tuples conform to the same relation schema;  the values in the same column belong to the same domain. Untyped perspective: there is a single domain, so the second condition can be dropped.

Steffen Staab Advanced Data Modeling 11 of 48 WeST Typed or untyped?  Consider the relation admire: admireradmired wimandy mikewim liamandy liamarsenal

Steffen Staab Advanced Data Modeling 12 of 48 WeST Database schema and instance  Relational database schema: a collection of relation schemas with distinct relation names.  Relational database instance conforming to a relational database schema S:  a mapping I from the relation names of S to relation instances such that for every relation schema r(a 1 :d 1, …, a n :d n ) in S the relation instance I(r) conforms to this relation schema.

Steffen Staab Advanced Data Modeling 13 of 48 WeST Unnamed perspective  No attributes  a tuple is simply a sequence (v_1, …, v_n) of values.  The components of tuples can therefore be identified by their position in the tuple.

Steffen Staab Advanced Data Modeling 14 of 48 WeST From Unnamed to Named Perspective  Introduce a collection of attributes #1,#2, …,  identify tuple (v 1, …, v n ) with the tuple { #1 = v 1, …,#n = v n }.  Likewise, identify relation schema r(d 1, …, d n ) with r(#1:d 1, …,#n:d n ).

Steffen Staab Advanced Data Modeling 15 of 48 WeST Relational Algebra and SQL 1. Can define new relations from existing ones; 2. Uses a collection of operations on relations to do so.

Steffen Staab Advanced Data Modeling 16 of 48 WeST Constant { (v 11, …, v 1n ), ….. (v k1, …, v kn ) }

Steffen Staab Advanced Data Modeling 17 of 48 WeST Union R 1 [ R 2 = {(c 1, …, c k ) | (c 1, …, c k ) 2 R 1 or (c 1, …, c k ) 2 R 2 }

Steffen Staab Advanced Data Modeling 18 of 48 WeST Set difference R_1 - R2 = {(c 1, …, c k ) | (c 1, …, c k ) 2 R 1 and (c 1, …, c k ) 2 R 2 }

Steffen Staab Advanced Data Modeling 19 of 48 WeST Cartesian product R1 £ R2 = {(c 1, …, c k, d 1, …, d m ) | (c1, …, c k ) 2 R 1 and (d 1, …, d m ) 2 R 2 }.

Steffen Staab Advanced Data Modeling 20 of 48 WeST Projection Let now R be a relation of arity k and i 1, …, i m be numbers in {1, …, k}. ¼ i 1, …, i m (R) = {(c i 1, …, c i m ) | (c 1, …, c k ) 2 R }. We say that ¼ i 1, …, i m (R) is obtained from R by projection (on arguments i 1, …, i m ).

Steffen Staab Advanced Data Modeling 21 of 48 WeST Selection Assume formulas on domains with “variables” #1, #2, …. For example, #1 = #2. ¾ F (R) = {(c 1, …, c k ) | (c 1, …, c k ) 2 R and F holds on (c 1, …, c k )}.

Steffen Staab Advanced Data Modeling 22 of 48 WeST Overview  Relational algebra, named perspective  SQL  Integrity constraints  (Aggregates and grouping)

Steffen Staab Advanced Data Modeling 23 of 48 WeST Constant { { a 1 = v 11, …, a n = v 1n }, … …… { a 1 = v k1, …, a n = v kn } }

Steffen Staab Advanced Data Modeling 24 of 48 WeST Union Let R1, R2 be relations with the same attributes. R1 [ R2 = { t | t 2 R 1 or t 2 R 2 }

Steffen Staab Advanced Data Modeling 25 of 48 WeST Union, example AB ® 1 ® 2 ¯ 1 AB ® 1 ® 2 ¯ 1 ¯ 3 AB ® 2 ¯ 3 R1R1 R2R2 R 1 [ R 2

Steffen Staab Advanced Data Modeling 26 of 48 WeST Renaming Let R be a relation whose set of attributes is a 1,…,a n, c 1,…,c m Let b 1, …, b n be distinct attributes such that {b 1, …, b n } Å { c 1, …, c m } = ; Then ½ a 1 ! b 1, …, a n ! b n (R) = {{b 1 = v 1, …, b n =v n, c 1 =w 1, …, c m =w m } | {a 1 = v 1, …, a n =v n, c 1 =w 1, …, c m =w m } 2 R}

Steffen Staab Advanced Data Modeling 27 of 48 WeST SQL SQL is based on set and relational operations with certain modifications and enhancements A typical SQL query has the form: select a 1, …, a n from R 1, …, R m where P This query is equivalent to relational algebra expression: ¼ a 1,…, a n ( ¾ P (R 1 £ … £ R m )) The result of an SQL query is a relation. Exceptions?

Steffen Staab Advanced Data Modeling 28 of 48 WeST Integrity constraints  Domain constraints.  Key constraints.  Foreign key constraints.  More general, defined constraints.  How to translate them?

Steffen Staab Advanced Data Modeling 29 of 48 WeST Query language Allow one to define:  Relation and database schemas;  Relations through our relations;  Integrity constraints;  Updates.