Discussion #22 1/10 Discussion #22 Relational Data Model.

Slides:



Advertisements
Similar presentations
Chapter 3 : Relational Model
Advertisements

Relational Model (CB Chapter 4) CPSC 356 Database Ellen Walker Hiram College.
Overview Begin 6:00 Quiz15 mins6:15 Review Table Terms25 mins6:40 Short Break10 mins6:50 SQL: Creating Tables60 mins7:50 Break10 mins8:00 Lab – Creating.
Cs3431 Constraints Sections 6.1 – 6.5. cs3431 Example CREATE TABLE Student ( sNum int, sName varchar (20), prof int, CONSTRAINT pk PRIMARY KEY (snum),
Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Relations The Relational Data Model John Sieg, UMass Lowell.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Basic (Flat) Relational Model.
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,
1 Minggu 2, Pertemuan 3 The Relational Model Matakuliah: T0206-Sistem Basisdata Tahun: 2005 Versi: 1.0/0.0.
SQL Keys and Constraints Justin Maksim. Key Declaration Key constraint defined within the CREATE TABLE command Key can be declared using either the PRIMARY.
Fall 2001Arthur Keller – CS 1803–1 Schedule Today Oct. 2 (T) Relational Model. u Read Sections Assignment 1 due. Personal Letter of Introduction.
Discussion #23 1/32 Discussion #23 Relational Algebra.
CS 405G: Introduction to Database Systems Lecture 4: Relational Model Instructor: Chen Qian.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
1 Pertemuan 04 MODEL RELASIONAL Matakuliah: >/ > Tahun: > Versi: >
Discussion #15 1/16 Discussion #15 Interpretations.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Database Architecture The Relational Database Model.
Chapter 6 Relations. Topics in this Chapter Tuples Relation Types Relation Values Relation Variables SQL Facilities.
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.
Chapter 4 The Relational Model.
START OF DAY 8 Reading: Chap. 2 & 9. Relational Data Model.
Chapter 3 The Relational Model Transparencies Last Updated: Pebruari 2011 By M. Arief
8.2 n-ary Relations and Their Applications
Relational Data Model. A Brief History of Data Models  1950s file systems, punched cards  1960s hierarchical  IMS  1970s network  CODASYL, IDMS 
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Relational Data Model and Relational Database Constraints.
THE RELATIONAL DATA MODEL CHAPTER 3 (6/E) CHAPTER 5 (5/E) 1.
CS 3630 Database Design and Implementation. 2 Mathematical Relation A mathematical relation is a subset of a Cartesian Product. A1  A2  A3  …  An.
10/9/20151 The Relational Data Model TCU Database Systems Last update: September 2004 Reference: Elmasri 4 th edition, chapter 5.
Page 1 Topic 4 Relational Databases CPS510 Database Systems Abdolreza Abhari School of Computer Science Ryerson University.
Module 3: The Relational Model.  Overview Terminology Relational Data Structure Mathematical Relations Database Relations Relational Keys Relational.
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.
1 The Relational Database Model. 2 Learning Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical.
1 Mathematical Relation A mathematical relation is a subset of a Cartesian Product. A1  A2  A3  …  An = {(x1, x2, x3, …, xn): xi  Ai} R  A1  A2.
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 Data Model Ch. 7.1 – 7.3 John Ortiz Lecture 3Relational Data Model2 Why Study Relational Model?  Most widely used model.  Vendors: IBM,
The Relational Model Pertemuan 03 Matakuliah: M0564 /Pengantar Sistem Basis Data Tahun : 2008.
Module Coordinator Tan Szu Tak School of Information and Communication Technology, Politeknik Brunei Semester
Chapter 2: Intro to Relational Model. 2.2 Example of a Relation attributes (or columns) tuples (or rows)
CS 338The Relational Model2-1 The Relational Model Lecture Topics Overview of SQL Underlying relational model Relational database structure SQL DDL and.
1 CS 430 Database Theory Winter 2005 Lecture 4: Relational Model.
CSE314 Database Systems Lecture 3 The Relational Data Model and Relational Database Constraints Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
Sets & Set Operations Tuples & Relations. Sets Sets are collections –The things in the collection are called elements or members –Sets have no duplicates.
Normalization MIS335 Database Systems. Why Normalization? Optimizing database structure Removing duplications Accelerating the instructions Data integrity!
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,
©Silberschatz, Korth and Sudarshan1 Structured Query Language (SQL) Data Definition Language Domains Integrity Constraints.
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
Date: 13/03/2015 Training Reference: 2015 GIS_01 Document Reference: 2015GIS_01/PPT/L4 Issue: 2015/L4/1/V1 Addis Ababa, Ethiopia GIS Data Base Management.
N-ary Relations & Their Applications. 2 n-ary Relations Let A 1, A 2, …, A n be sets. An n-ary relation on these sets is a subset of A 1 x A 2 x … x A.
The Relational Model © Pearson Education Limited 1995, 2005 Bayu Adhi Tama, M.T.I.
CS 3630 Database Design and Implementation. 2 Mathematical Relation A mathematical relation is a subset of a Cartesian Product. A1  A2  A3  …  An.
Chapter 3 The Relational Model. Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between mathematical.
Relational Algebra. What is an algebra? –a pair: (set of values, set of operations) –  ADT  type  Class  Object e.g., stack: (set of all stacks, {pop,
INFORMATION TECHNOLOGY DATABASE MANAGEMENT. A database is a collection of information organized to provide efficient retrieval. The collected information.
Chapter 4 The Relational Model Pearson Education © 2009.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
Introduction to Database Programming with Python Gary Stewart
Relational Data Model.
Translation of ER-diagram into Relational Schema
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
The Relational Model Transparencies
CMSC-461 Database Management Systems
CS 405G: Introduction to Database Systems
Presentation transcript:

Discussion #22 1/10 Discussion #22 Relational Data Model

Discussion #22 2/10 Topics Databases Relational database Relations and schemas –Keys –Tuples and predicates

Discussion #22 3/10 Database A persistent collection of information about various kinds of objects (persons, places, things, events). Each object or entity can be characterized by a set of attributes or properties from a domain. e.g.person(SSN, Name, Address, Phone) Each individual object has a value associated with it for each attribute; this is a tuple and forms a record. e.g.SSN: Name:Pat Carter Address:12 Main Phone: A set of records is a file (relation, for a relational database). A collection of files is a database (relations or tables, for a relational database). Typical operations on a database: –insert– data retrieval –delete– summarize data (e.g. averages, totals, mins, …) –update– create/delete files A database system helps people manage databases. –data storage –integrity / security –crash recovery

Discussion #22 4/10 StudentIDNameAddressPhone 12345C. Brown12 Apple St L. Van Pelt34 Pear Ave P. Patty56 Grape Blvd Snoopy12 Apple St CourseStudentIDGrade CS A CS B EE C EE B+ EE B CS A- PH C+ CourseDayHour CS101M9AM CS101W9AM CS101F9AM EE200Tu10AM EE200W1PM EE200Th10AM PH100Tu11AM CoursePrerequisite CS101CS100 EE200EE005 EE200CS100 CS120CS101 CS121CS120 CS205CS101 CS206CS121 CS206CS205 CourseRoom CS101Turing Aud. EE20025 Ohm Hall PH100Newton Lab. Relational Database Example snapcr cdhcsg cp

Discussion #22 5/10 Relational Schemas Each relation has a schema –name –set of attributes –domain for each attribute Example: –Names: snap, cp, cdh, cr, csg –Attributes:table headers –Domains:studentID: integer all the rest are strings, but we could be more specific (e.g. time, day, grade)

Discussion #22 6/10 Relational Tables Table tuples are n-tuples, where n is the arity or degree of the relation (i.e. the number of attributes). Each n-tuple t  D 1  D 2  …  D n, where the D i ’s are the domains. e.g. a 3-tuple t of cdh is an element string  string  string or string  day  time or course  day  time depending on how specific we make our domains. A table is a set of tuples, all with the same schema e.g. cdh  D course  D day  D hour

Discussion #22 7/10 Tuple Sets (Relations, Tables) & Keys Because a table is a set of tuples, there are no duplicates. Thus, there is always a set of attributes whose values uniquely identify a tuple (even if it is all of them). A set of attributes whose values always uniquely identify a tuple constitutes a key. Typically, one or two attributes make up a key. Keys must be declared  we cannot assume uniqueness. e.g. Name is not a key  there could be another C. Brown Some systems add a tuple identifier as the key.

Discussion #22 8/10 Keys  Examples TableKey snapStudentID Name, Address, Phone (possible key?) cpCourse Prerequisite cdhCourse Day Hour Can a course meet twice on the same day? If not:Course Day crCourse Room Does a course always meet in the same room? If so:Course csgCourse StudentID

Discussion #22 9/10 Predicates and Tuples A table name for tuples of arity n is an n-place predicate. –cdh('CS101','M','9AM') –Asserts that CS101 meets on Monday at 9:00 am. Predicates give each tuple a meaning in the ordinary sense of predicates. –The subset of D 1  D 2  …  D n present in the database are those assigned T; all others are assigned F. (Closed-World Assumption) –Interpretation: Domain For each predicate and every substitution, T or F.

Discussion #22 10/10 Database Tuples Database tuples (strictly speaking) are not true subsets of D 1  D 2  …  D n because we can alter the column order if we do so “correctly.” More properly defined, a tuple in a relation is a set of attribute-value pairs. –e.g. {(Course, 'CS101'), (Day, 'M'), (Hour, '9AM') } = {(Day, ' M ' ), (Course, ' CS101 ' ), (Hour, ' 9AM ' ) } –Normally, we factor out the attribute and fix the order. –Implication: we can interchange columns. cr = Course Room =RoomCourse CS101 Turing Aud.Turing Aud.CS101 EE Ohm Hall25 Ohm HallEE200 PH100 Newton Lab.Newton Lab.PH100