Relational Model CMSC 461 Michael Wilson. What is a relation?  A relation is a set of tuples  (d 1, d 2, d 3, …, d n )  Where each element d i is a.

Slides:



Advertisements
Similar presentations
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
Advertisements

Relational Model (CB Chapter 4) CPSC 356 Database Ellen Walker Hiram College.
Normalization continued CMSC 461 Michael Wilson. Normalization clarification  Normalization is simply a way of reducing anomalous database behavior 
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
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.
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
Chapter 3: Relational Model
1 Minggu 2, Pertemuan 3 The Relational Model Matakuliah: T0206-Sistem Basisdata Tahun: 2005 Versi: 1.0/0.0.
CS 405G: Introduction to Database Systems Lecture 4: Relational Model Instructor: Chen Qian.
Thomas Connolly and Carolyn Begg’s
Relational Database Management System A type of database in which records are stored in relational form is called relational database management system.
Database Design & ER Diagrams
Database Architecture The Relational Database Model.
1 Relational model concepts Key constraints Referential integrity constraint Steen Jensen, autumn 2013.
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.
© Pearson Education Limited, Chapter 2 The Relational Model Transparencies.
Relational Model Session 6 Course Name: Database System Year : 2012.
1 The Relational Data Model, Relational Constraints, and The Relational Algebra.
Chapter 3 The Relational Model Transparencies Last Updated: Pebruari 2011 By M. Arief
Content Resource- Elamsari and Navathe, Fundamentals of Database Management systems.
CSC 280: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS Dr. Adam Anthony Fall 2012.
Relational databases and third normal form As always click on speaker notes under view when executing to get more information!
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Intro to Relational.
Database Management System Lecture 4 The Relational Database Model- Introduction, Relational Database Concepts.
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 6005 – Database Management Systems Design Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 2 – Relational Model.
MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj RM/SQL Lecture 1 ©Akhilesh Bajaj, 2000, 2002, 2003, All.
Copyright © Curt Hill The Relational Model of Database Basic organization and terms.
1 The Relational Model. 2 Why Study the Relational Model? v Most widely used model. – Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. v “Legacy.
FALL 2004CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
1.1 CAS CS 460/660 Relational Model. 1.2 Review E/R Model: Entities, relationships, attributes Cardinalities: 1:1, 1:n, m:1, m:n Keys: superkeys, candidate.
Relational Algebra CMSC 461 Michael Wilson. Relational algebra  Before we get into SQL, want to take a look at what exactly SQL is really modeling 
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com ICOM 5016 – Introduction.
Slide Chapter 5 The Relational Data Model and Relational Database Constraints.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Intro to Relational.
Databases Illuminated Chapter 3 The Entity Relationship Model.
Announcements Reading for Monday –4.6 Homework 3 – Due 9/29.
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)
12/2/2015CPSC , CPSC , Lecture 41 Relational Model.
Normalization MIS335 Database Systems. Why Normalization? Optimizing database structure Removing duplications Accelerating the instructions Data integrity!
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 5 – September 4 th,
Copyright, Harris Corporation & Ophir Frieder, Relational Definitions.
Relational Data Model DeSiaMore Powered by DeSiaMore.
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,
SE305 Database System Technology 25/09/2014 Quiz-1.
April 20022CS3X1 Database Design The relational model John Wordsworth Department of Computer Science The University of Reading
Jennifer Widom Relational Databases The Relational Model.
SQL constrains and keys. SORTED RESULTS Sort the results by a specified criterion SELECT columns FROM tables WHERE predicates ORDER BY column ASC/DESC;
The Relational Model © Pearson Education Limited 1995, 2005 Bayu Adhi Tama, M.T.I.
Mapping ER to Relational Model Each strong entity set becomes a table. Each weak entity set also becomes a table by adding primary key of owner entity.
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 LM2 ER & EER Model. Learning Objectives: Explain importance of data modeling Define and use the entity-relationship model Define E/R terms Describe.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
1 CS122A: Introduction to Data Management Lecture #4 (E-R  Relational Translation) Instructor: Chen Li.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
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.
ER Diagrams and Relational Model CS 174a (Winter 2015)
Chapter 2: Relational Model
Data Base System Lecture 6: Relational Model
Relational Databases The Relational Model.
Relational Databases The Relational Model.
Design tools and techniques for a relational database system
INSTRUCTOR: MRS T.G. ZHOU
Presentation transcript:

Relational Model CMSC 461 Michael Wilson

What is a relation?  A relation is a set of tuples  (d 1, d 2, d 3, …, d n )  Where each element d i is a member of D i, which is the data domain for d i  The order of the tuples in the set is irrelevant  A data domain describes all unique values that a particular data element may contain  Corresponds to data types  Each element is called an attribute value

A picture jacked shamelessly from Wikipedia

An example UMBC IDAgeFNameLNameGPA SM Mario 4.0 SM LuigiMario3.9 MT SamusAran4.0 FF SnowVilliers0.2 SW SnowWhite3.5

Relation schemas  Relation schemas are basically groups of named attributes along with any constraints on the data housed by the attribute  For the previous example, the relation schema would be:  UMBC ID, Age, FName, LName, GPA  String, Integer, String, String, Double

Translating to database terminology  A relation looks a lot like a table  An attribute looks a lot like a column  A tuple looks a lot like a row  Finally, a database contains many tables  A database can be thought of as a set of relations

Differences between relations and tables  Very minor stuff  A table can have duplicate rows, whereas a relation cannot have duplicate tuples  Tables have some metadata associated with them for programmatic reasons

Identification of tuples  To identify a tuple, typically we’ll take a subset of the values in the tuple in order and refer to it that way  Any subset of values that can uniquely identify the tuple is called a superkey  Uniquely identifying a tuple requires that the superkey be unique  As long as the subset itself is unique, it works  Even if one or more values are shared between superkeys

Superkeys! UMBC IDAgeFNameLNameGPA SM Mario 4.0 SM LuigiMario3.9 MT SamusAran4.0 FF SnowVilliers0.2 SW SnowWhite3.5

Superkeys! UMBC IDAgeFNameLNameGPA SM Mario 4.0 SM LuigiMario3.9 MT SamusAran4.0 FF SnowVilliers0.2 SW SnowWhite3.5

More superkeys! Record IDPatientNameDate of VisitDiagnosis 14233Mario 04/28/1991Leg injury Snow Villiers12/05/2012Brain damage Lara Croft12/05/2012Powder burns

More superkeys! Record IDPatientNameDate of VisitDiagnosis 14233Mario 04/28/1991Leg injury Snow Villiers12/05/2012Brain damage Lara Croft12/05/2012Powder burns

More superkeys! Record IDPatientNameDate of VisitDiagnosis 14233Mario 04/28/1991Leg injury Snow Villiers12/05/2012Brain damage Lara Croft12/05/2012Powder burns

More superkeys! Record IDPatientNameDate of VisitDiagnosis 14233Mario 04/28/1991Leg injury Snow Villiers12/05/2012Brain damage Lara Croft12/05/2012Powder burns

What use is a superkey?  In the previous examples, we’ve got multiple possible superkeys  What use are they?  Allows us to introduce a secondary concept, really

Candidate keys  A candidate key is a superkey that contains the fewest number of values that can uniquely identify a tuple  A relation can have multiple candidate keys

Candidate keys? Record IDPatientNameDate of VisitDiagnosis 14233Mario 04/28/1991Leg injury Snow Villiers12/05/2012Brain damage Lara Croft12/05/2012Powder burns

Choosing a candidate key  A candidate key is a superkey that contains the fewest number of values that can uniquely identify a tuple  A relation can have multiple candidate keys  How do you know which one to choose?

Choosing a candidate key  This is actually somewhat of an art  The answer, really, is to choose the one that best suits your data  Looking at ER Diagrams can help you decide

Primary keys  When you’ve chosen a candidate key to use, you’ve chosen a primary key  The primary key is the way you reference items in your relation  There will be much more on this later

Some examples  phpBB -  phpBB uses 63 tables