CS405G: Introduction to Database Systems

Slides:



Advertisements
Similar presentations
IS698: Database Management Min Song IS NJIT. The Relational Data Model.
Advertisements

The Relational Model System Development Life Cycle Normalisation
 CS 405G: Introduction to Database Systems Lecture 7: Relational Algebra II Instructor: Chen Qian Spring 2014.
Relational Model and Relational Algebra Rose-Hulman Institute of Technology Curt Clifton.
CS405G: Introduction to Database Systems Final Review.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 5 Normalization of Database Tables.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Database Design & ER Diagrams
Midterm 1 Concepts Relational Algebra (DB4) SQL Querying and updating (DB5) Constraints and Triggers (DB11) Unified Modeling Language (DB9) Relational.
CS 405G: Introduction to Database Systems 16. Functional Dependency.
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 9.1.
Web-Enabled Decision Support Systems
CMPE 226 Database Systems September 16 Class Meeting Department of Computer Engineering San Jose State University Fall 2015 Instructor: Ron Mak
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 5 Normalization of Database.
Instructor: Jinze Liu Fall Basic Components (2) Relational Database Web-Interface Done before mid-term Must-Have Components (2) Security: access.
Relational Data Model Ch. 7.1 – 7.3 John Ortiz Lecture 3Relational Data Model2 Why Study Relational Model?  Most widely used model.  Vendors: IBM,
11/07/2003Akbar Mokhtarani (LBNL)1 Normalization of Relational Tables Akbar Mokhtarani LBNL (HENPC group) November 7, 2003.
Normalization of Database Tables
CS 405G: Introduction to Database Systems
CS 157B Database Systems Dr. T Y Lin. Updates 1.Red color denotes updated data (ppt) 2.Class participation will be part of “extra” credits to to “quiz.
 CS 405G: Introduction to Database Systems Lecture 6: Relational Algebra Instructor: Chen Qian.
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2009.
Chapter 8 Relational Database Design. 2 Relational Database Design: Goals n Reduce data redundancy (undesirable replication of data values) n Minimize.
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.
Midterm Review. Main Topics ER model Relational model Relational Database Design (Theory)
Relational Algebra Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 4.
Functional Dependency and Normalization
Module 2: Intro to Relational Model
Relational Model By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany)
Chapter 2: Relational Model
Chapter 5: Logical Database Design and the Relational Model
Chapter 2: Intro to Relational Model
CS411 Database Systems 08: Midterm Review Kazuhiro Minami 1.
Canonical Cover & Normal Forms
Quiz Questions Q.1 An entity set that does not have sufficient attributes to form a primary key is a (A) strong entity set. (B) weak entity set. (C) simple.
CS411 Database Systems 08: Midterm Review Kazuhiro Minami 1.
CIS 207 The Relational Database Model
CPSC-310 Database Systems
Lecture 2 The Relational Model
Chapter 4 Relational Databases
Payroll Management System
Chapter 2: Intro to Relational Model
CS 405G: Introduction to Database Systems
Translation of ER-diagram into Relational Schema
CMPE 226 Database Systems February 21 Class Meeting
CS 405G: Introduction to Database Systems
From ER to Relational Model
Relational Database.
CS 405G: Introduction to Database Systems
Canonical Cover & Normal Forms
Normalization Murali Mani.
Functional Dependencies and Normalization
The Relational Model Textbook /7/2018.
Normalization.
Chapter 2: Intro to Relational Model
CS 405G: Introduction to Database Systems
Chapter 2: Intro to Relational Model
CS 405G: Introduction to Database Systems
Chapter 2: Intro to Relational Model
Normalization February 28, 2019 DB:Normalization.
Example of a Relation attributes (or columns) tuples (or rows)
Chapter 2: Intro to Relational Model
Relational Database Design
Database Dr. Roueida Mohammed.
Terminology Product Attribute names Name Price Category Manufacturer
Database Systems: Design, Implementation, and Management
Database.
CS 405G: Introduction to Database Systems
Recap – Relational languages
Presentation transcript:

CS405G: Introduction to Database Systems

Announcement Today Review Friday Go over homework Course evaluation

Materials Review for final Book Slides ( should be all on the course website) Homework Quizzes Mid-Term

Jinze Liu @ University of Kentucky Database Design 11/16/2018 Jinze Liu @ University of Kentucky

E-R model E-R model Entities Attributes Relationships

Jinze Liu @ University of Kentucky 11/16/2018 Jinze Liu @ University of Kentucky

Database Design 11/16/2018 11/16/2018 7 7 7

From E-R Diagram to Relations Schemas Converting E-R diagram to relations Keys Super keys Candidate keys Primary keys Relational integrity constraints

Jinze Liu @ University of Kentucky Key Constraints Superkey: (Uniqueness constraints) A set of attributes where no two distinct tuples can have the same values Every relation has at least one superkey: The set of all attributes. Key: A minimal superkey Uniqueness constraint (superkey) Minimum Constraint No attribute can be removed and still satisfy the uniqueness constraints. 11/16/2018 Jinze Liu @ University of Kentucky 6

Relational Integrity Constraints Constraints are conditions that must hold on all valid relation instances. There are four main types of constraints: Domain constraints The value of a attribute must come from its domain Key constraints Entity integrity constraints Referential integrity constraints 11/16/2018 11/16/2018 10 10 10

Database Normalization Functional Dependency Functional Closure Keys Redefined Based on functional dependency DB Norm Form 1st, 2nd, 3rd, BCNF

Three Types of non-key DF X A X  A Partial dependency key X A X  A Transitive dependency I key X A X  A Transitive dependency II 11/16/2018 Luke Huan Univ. of Kansas

Luke Huan Univ. of Kansas 3NF R is in Third Normal Form (3NF) if for every non-trivial FD X -> A (where A is single attribute), either X is a superkey of R, or A is a member of at least one key of R Intuitively, BCNF decomposition on X -> A would “break” the key containing A X A X A X A Partial dependency Transitive dependency I Transitive dependency II 2NF 3NF BCNF 2NF  3NF  BCNF 11/16/2018 Luke Huan Univ. of Kansas

Luke Huan Univ. of Kansas Database Query 11/16/2018 Luke Huan Univ. of Kansas

Relational Algebra and SQL SQL query SFW Group by …, Having Subqueries Relationship between R.A. and SQL

Jinze Liu @ University of Kentucky Relational algebra A language for querying relational databases based on operators: RelOp RelOp Core set of operators: Selection, projection, cross product, union, difference, and renaming Additional, derived operators: Join, natural join, intersection, etc. Compose operators to make complex queries We are gonna cover this in one day! Possible because of the minimalist approach. 11/16/2018 Jinze Liu @ University of Kentucky

Summary of core operators Selection: Projection: Cross product: Union: Difference: Renaming: Does not really add “processing” power σp R πL R R X S R S R - S ρ S(A1, A2, …) R 11/16/2018 Jinze Liu @ University of Kentucky

Summary of derived operators R p S R  S R S Join: Natural join: Intersection: 11/16/2018 Jinze Liu @ University of Kentucky

Classification of relational operators Selection: σp R Projection: πL R Cross product: R X S Join: R p S Natural join: R  S Union: R U S Difference: R - S Intersection: R ∩ S Monotone Monotone w.r.t. R; non-monotone w.r.t S 11/16/2018 Jinze Liu @ University of Kentucky

Update Operations on Relations INSERT a tuple. DELETE a tuple. MODIFY a tuple. Constraints should not be violated in updates 11/16/2018 Jinze Liu @ University of Kentucky

Basic queries: SFW statement SELECT A1, A2, …, An FROM R1, R2, …, Rm WHERE condition; Also called an SPJ (select-project-join) query (almost) Equivalent to relational algebra query π A1, A2, …, An (σ condition (R1 X R2 X … X Rm)) 11/16/2018 Luke Huan Univ. of Kansas

Luke Huan Univ. of Kansas Semantics of SFW SELECT E1, E2, …, En FROM R1, R2, …, Rm WHERE condition; For each t1 in R1: For each t2 in R2: … … For each tm in Rm: If condition is true over t1, t2, …, tm: Compute and output E1, E2, …, En as a row t1, t2, …, tm are often called tuple variables Not 100% correct, we will see 11/16/2018 Luke Huan Univ. of Kansas

Operational semantics of GROUP BY SELECT … FROM … WHERE … GROUP BY …; Compute FROM Compute WHERE Compute GROUP BY: group rows according to the values of GROUP BY columns Compute SELECT for each group For aggregation functions with DISTINCT inputs, first eliminate duplicates within the group Number of groups = number of rows in the final output 11/16/2018 Jinze Liu @ University of Kentucky

Jinze Liu @ University of Kentucky Database Design 11/16/2018 Jinze Liu @ University of Kentucky

Jinze Liu @ University of Kentucky A DBMS Overview 11/16/2018 Jinze Liu @ University of Kentucky

physical data organization Storage hierarchy (Lexington vs. Pluto) ! count I/O’s Disk geometry: three components of access cost; random vs. sequential I/O Data layout Record layout (handling variable-length fields, NULL’s) Block layout (NSM, PAX) ! inter-/intra-record locality Access paths Primary versus secondary indexes Tree-based indexes: ISAM, B+-tree ! Again, reintroduce redundancy to improve performance ! Fundamental trade-off: query versus update cost