RELATIONAL DATABASES. Relational data Structure RELATION: Table with columns and rows ATTRIBUTE: Column of a relation DOMAIN: Set of allowable values.

Slides:



Advertisements
Similar presentations
SQL. More than 100 DBMS support SQL –Used by DBAs and application programmers –Structured Query Language or SEQUEL –ORACLE-> relation database based on.
Advertisements

The Relational Model Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
CSC271 Database Systems Lecture # 5. Summary: Previous Lecture  Database languages  Functions of a DBMS  DBMS environment  Data models and their categories.
Relational Model (CB Chapter 4) CPSC 356 Database Ellen Walker Hiram College.
RELATIONAL ALGEBRA Lecture Relational Algebra Operations to manipulate relations. Used to specify retrieval requests (queries). Query results in.
Branch (Bno, Street, Area, City, Pcode, Tel_No, Fax_NO) Staff (Sno, FName, LName, Address, Tel_No, Position, Sex, DOB, Salary, NIN, Bno) Property_for_Rent.
Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Relations The Relational Data Model John Sieg, UMass Lowell.
Lesson II The Relational Model © 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 Minggu 2, Pertemuan 3 The Relational Model Matakuliah: T0206-Sistem Basisdata Tahun: 2005 Versi: 1.0/0.0.
1 Pertemuan 04 MODEL RELASIONAL Matakuliah: >/ > Tahun: > Versi: >
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 Architecture The Relational Database Model.
Chapter 3 Relational Model Chapter 4 in Textbook.
CSC271 Database Systems Lecture # 6. Summary: Previous Lecture  Relational model terminology  Mathematical relations  Database relations  Properties.
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.
© 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 4 The Relational Model.
Chapter 3 The Relational Model Transparencies Last Updated: Pebruari 2011 By M. Arief
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.
Agenda TMA01 M876 Block 3 – Using SQL Structured Query Language - SQL A non-procedural language to –Create database and relation structures. –Perform.
1 The Relational Database Model. 2 Learning Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical.
B. Information Technology (Hons.) CMPB245: Database Design Logical Database Design.
9/7/2012ISC329 Isabelle Bichindaritz1 The Relational Database Model.
1 General Form of the SELECT Statement SELECT [DISTINCT | ALL {* | col_expr [AS new_name] [,…]} FROMtable_name [,…] [,…] [WHERE condition] [GROUP BY col_list]
The Relational Model Pertemuan 03 Matakuliah: M0564 /Pengantar Sistem Basis Data Tahun : 2008.
Relational Database. Database Management System (DBMS)
CS 3630 Database Design and Implementation. Database Schema Branch (Bno…) Staff (Sno…Bno) Owner (Ono…) PropertyForRent (Pno…Ono) Renter (Rno…) Viewing.
IST 210 SQL Todd Bacastow IST 210: Organization of Data.
1 Geog 357 – Introduction to GIS The Relational Language.
12/2/2015CPSC , CPSC , Lecture 41 Relational Model.
L8-2-S1 Misc Topics © M.E. Fayad SJSU -- CmpE Database Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of.
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,
Chapter 4 Practice Problem Solutions. A list (Bno, Street, Area,Tel_No, Fax_No) of branches located in Bay Area Branch (Bno, Street, Area, City, Pcode,
Branch (Bno, Area, City, Pcode) Staff (Sno, FName, LName, Position, Sex, DOB, Salary, Bno) Property_for Rent (Pno, Area, City, Type, Rooms, Rent, Ono,
2 Database Design Chapter Operations of the Relational Model Updates: changes the database’s state. Insert Delete Update/modify Retrievals: does.
CHAPTER 2 : RELATIONAL DATA MODEL Prepared by : nbs.
The Relational Model © Pearson Education Limited 1995, 2005 Bayu Adhi Tama, M.T.I.
CSCI 6315 Applied Database Systems Review for Midterm Exam I Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539
Chapter 3 The Relational Model. Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between mathematical.
Chapter 2 The Relational Model. 2-2 In This Chapter You Will Learn   What a data model is and what its uses are   The terminology of the relational.
Chapter 4 The Relational Model Pearson Education © 2009.
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
Chapter 4 Relational Algebra Chapter 4 in Textbook.
Teacher Workshop Database Design Pearson Education © 2014.
Relational Algebra Lecture 2.
CS 3630 Database Design and Implementation
Database Design The Relational Model Text Ch5
The Relational Database Model
Data Base System Lecture 6: Relational Model
Chapter 3 The Relational Model.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter Name SQL: Data Manipulation
Chapter 4+17 The Relational Model Pearson Education © 2014.
Chapter 4 The Relational Model Pearson Education © 2009.
The Relational Model Transparencies
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Design tools and techniques for a relational database system
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 3 The Relational Model
RELATIONAL DATA MODEL - 1
Presentation transcript:

RELATIONAL DATABASES

Relational data Structure RELATION: Table with columns and rows ATTRIBUTE: Column of a relation DOMAIN: Set of allowable values for one or more attributes TUPLE: Row of a relation DEGREE of a relation: Number of attributes CARDINALITY of a relation: –Number of tuples it contains Relational Database: A collection of normalized relations Fig 3.1 pg 75 Fig 3.2 pg 76

Alternate terminology for relational model terms Formal Terms Alternative 1Alternative 2 RelationTableFile TupleRowRecord AttributeColumnField

Mathematical Relations D1={2,4} and D2={1,3,5} D1 x D2= {(2,1),(2,3),(2,5),(4,1),(4,3),(4,5)} R={(2,1),(4,1)} D1={1,3} D2={2,4} D3={5,6} D1 x D2 x D3 = –{(1,2,5),(1,2,6),(1,4,5),(3,2,5),(3,2,6),(3,4,5),(3,4,6)}

DATABASE RELATIONS Relation Schema: A relation name followed by a set of attribute and domain name pairs. A1,A2,…..An be attributes with domains D1,D2,….Dn {A1:D1,A2:D2,…….An:Dn} is a relation schema Relation R is a set of n-tuples: (A1:d1,A2:d2,…..An:dn) such that d1  D1, d2  D2 …….dn  Dn {(Bno: B5, Street: 22 Deer Rd, Area: Sidcup, City: London, Pcode:SW1 4EH, Tel_No: , Fax_No: }

Properties of Relations Relation has a name that is distinct Each cell of the relation contains exactly (single) value Each attribute has a distinct name The values of the attribute form the same domain The order of the attributes have no significance Each tuple is distinct; no duplicate tuples The order of the tuples has no significance Relations do not contain repeating groups –two telephone nos for a single branch office in a single cell. First Normal Form

Relational Keys Superkey: An attribute or set of attributes that uniquely identifies a tuple within a relation Candidate Key: A superkey such that no proper subset is a superkey within the relation –several candidate keys for a relation. –Composite Key: when a key consists of more than one attribute. Primary Key: The candidate key that is selected to identify tuples uniquely within the relation Alternate key: The candidate keys that are not selected to be the primary key Foreign Key: An attribute or set of attributes within on relation that matches the candidate key of some (possibly the same) relation

Representing Relational Database Schemas A relational database consists of a number of relations. Relational schemas Branch: (Bno, Street, Area, City, Pcode, tel_No, fax_No) Staff:(Sno, Fname, Lname, Address, tel_No, Position, Sex, DOB, Salary, NIN, Bno) Property_for_RentPno, Street, Area, City, Pcode, Type, Rooms, Rent, Ono, Sno, Bno) Renter(Rno, Fname, Lname, Address, Tel_No, Pref_Type, Max_Rent, Bno) Owner(Ono, Fname, Lname, Address, Tel_No) Viewing(Rno, Pno, Date, Comment) Fig pg83

Relational Integrity Null –Value currently unknown or not applicable Entity Integrity –No attribute of a primary key can be null Referential Integrity –Foreign key value must match a candidate key value Enterprise constraints –Additional rule specified

Selection Operation List all staff with a salary greater than $10,000  salary > (Staff) logical operators  (AND),  (OR) and ~ (NOT)

Projection Operation List of salaries for all staff, showing only Sno, Fname, Lname and Salary details  sno, fname, lname, salary (Staff) Sno Fname Lname Salary SL21 JohnWhite SA25 ReneHowe SF31 AlLee S55 MaryAnn 30000

Cartesian Product Operation (  rno, fname, lname (Renter)) x (  rno, no,comment (Viewing)) abab aaabbbaaabbb R SR x S

Tuples where Renter.Rno = Viewing.Rno  renter.rno = viewing.rno ((  rno, fname, lname (Renter)) x (  rno, no,comment (Viewing))) Renter.RnoFnameLnameViewing.RnoPnoComment CR76JohnKayCR76PG4too remote CR79RickBayCR79PG4 CR88MollyHollyCR88PG4too small CR96BobRayCR96PG4no dining room

Union Operation Construct a list of all areas where there is either a branch or a property  area (Branch)   area (Property_for_rent) Area Sidcup Dyce Patrick Leigh dee Kilbern Hynland

Set Difference Operation Construct a list of all cities where there is a branch office but no properties  city (Branch) -  city (Property_for_rent) City Bristol

Natural Join Operation List the names and comments of all renters who have viewed a property  rn,fname,lname (Renter)  rno,pno,comment (Viewing) Renter.RnoFnameLnameViewing.RnoPnoComment CR76JohnKayCR76PG4too remote CR79RickBayCR79PG4 CR88MollyHollyCR88PG4too small CR96BobRayCR96PG4no dining room A B C a 1 x a 1 y T U

Left Outer Join Operation Produce a status report on property listings  rpno,street,city (Property_for_Rent) Viewing PnoStreetCityRnoDateComment PA1416HolheadAberdeenCR5624-May-98too small PA1416HolheadAberdeenCR6214-May-98no dining PL946ArgyllLondonnull null null PG4Lawrence St.GlasgowCR7620-Apr-98too remote PG4Lawrence St.GlasgowCR5627-May-98 PG362Manon Rd GlasgowCR5628-Apr-98

Views View: A dynamic result of one or more relational operation to produce another relation A view is a relation, but does not exist in storage Views are dynamic

Purpose of Views Hiding parts of the database from some users –Staff records without Salary attribute Same data can be seen by different users in different ways at the same time A view may be a join of two relations Order of columns may be changed