Department of Computer Science and Engineering, HKUST Slide 1 Notation Summary R, S: table schemas such as Branch (branch-name, branch-city, assets) Account.

Slides:



Advertisements
Similar presentations
The Relational Model Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Advertisements

Relational Database Design UNIT II 1. 2 Advantages of Using Database Systems Centralized control of a firm’s data Redundancy can be reduced (avoid keeping.
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
Relational Databases - Amit Bhawnani & Nimesh Shah.
SQL Constraints and Triggers
©Silberschatz, Korth and Sudarshan3.1Database System Concepts Chapter 3: Relational Model Structure of Relational Databases Relational Algebra Tuple Relational.
Temple University – CIS Dept. CIS331– Principles of Database Systems V. Megalooikonomou Query by example (based on notes by Silberchatz,Korth, and Sudarshan.
©Silberschatz, Korth and Sudarshan4.1Database System Concepts Modification of the Database – Deletion Delete all account records at the Perryridge branch.
Department of Computer Science and Engineering, HKUST Slide 1 Multivalue attribute: contains more than one value Employee Phone Employee Mobile PhoneHome.
MySQL Tutorial Introduction to Database. Learning Objectives  Read and write Data Definition grammar of SQL  Read and write data modification statements.
Department of Computer Science and Engineering, HKUST Slide 1 7. Relational Database Design.
Chapter 6: Integrity Objective Key Constraints (Chapter 2) Cardinality Constraints (Chapter 2) Domain Constraints Referential Integrity Assertions Triggers.
Chapter 3 Relational Model Chapter 4 in Textbook.
1 Relational model concepts Key constraints Referential integrity constraint Steen Jensen, autumn 2013.
CS 370 Database Systems Lecture 13 Introduction to SQL.
Department of Computer Science and Engineering, HKUST Slide 1 Comp 231 Database Management Systems Comp 231 Database Management Systems 6. Integrity Constraints.
©Silberschatz, Korth and Sudarshan6.1Database System Concepts Chapter 6: Integrity and Security Domain Constraints Referential Integrity Assertions Triggers.
1 Introduction to modeling Relational modelling Slides for this part are based on Chapters 11 from Halpin, T. & Morgan, T. 2008, Information Modeling and.
©Silberschatz, Korth and Sudarshan5.1Database System Concepts Chapter 5: Other Relational Languages Query-by-Example (QBE) Datalog.
Structured Query Language 2 Presented by: Annisa, M.Kom. Source: Database System Concepts 5 th edition.
DATA MODELING AND DATABASE DESIGN
Relational Algebra Instructor: Mohamed Eltabakh 1.
SCUHolliday - coen 1789–1 Schedule Today: u Constraints, assertions, triggers u Read Sections , 7.4. Next u Triggers, PL/SQL, embedded SQL, JDBC.
-- Introduction to database principles Maoying Wu March 25, 2013 Chapter 4: Advanced SQL (1)
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen M:N Relationships & Bridge Classes These.
SQL Databases are a Moving Target Juan F. Sequeda – Syed Hamid Tirmizi –
DBSQL 3-1 Copyright © Genetic Computer School 2009 Chapter 3 Relational Database Model.
Database System Concepts, 5 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Relational.
Chapter 2 Adapted from Silberschatz, et al. CHECK SLIDE 16.
Chapter 3: Relational Model  Structure of Relational Databases  Normal forms (chap. 7)  Reduction of an E-R Schema to Relational (Sect. 2.9)  Relational.
CIS552Relational Model1 Structure of Relational Database Relational Algebra Extended Relational-Algebra-Operations Modification of the Database.
©Silberschatz, Korth and Sudarshan5.1Database System Concepts Chapter 5: Other Relational Languages Query-by-Example (QBE)
M1G Introduction to Database Development 2. Creating a Database.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com ICOM 5016 – Introduction.
CS 370 Database Systems Lecture 11 Relational Algebra.
3.1Database System Concepts Chapter 3: Relational Model Structure of Relational Databases Relational Algebra Tuple Relational Calculus Domain Relational.
Triggers. Why Triggers ? Suppose a warehouse wishes to maintain a minimum inventory of each item. Number of items kept in items table Items(name, number,...)
©Silberschatz, Korth and Sudarshan5.1Database System Concepts Chapter 5: Other Relational Query Languages Tuple Relational Calculus Domain Relational Calculus.
Chapter 8: SQL. Data Definition Modification of the Database Basic Query Structure Aggregate Functions.
Computing & Information Sciences Kansas State University Monday, 17 Sep 2007CIS 560: Database System Concepts Lecture 12 of 42 Monday, 18 February 2008.
Source: Database System Concepts, Silberschatz etc Edited: Wei-Pang Yang, IM.NDHU, Introduction to Database CHAPTER 5 Other Relational Languages.
Chapter 2: Relational Model II Relational Algebra basics Relational Algebra basics.
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.
©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)
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences The Relational.
Relational Algebra HW2 Turn in as a hardcopy at the start of next class period. You may work this assignment in groups.
ICOM 5016 – Introduction to Database Systems Lecture 6 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
©Silberschatz, Korth and Sudarshan1 Structured Query Language (SQL) Data Definition Language Domains Integrity Constraints.
MIS 3053 Database Design And Applications The University Of Tulsa Professor: Akhilesh Bajaj Normal Forms Lecture 1 © Akhilesh Bajaj, 2000, 2002, 2003.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Relational State Assertions These slides.
ASET Relational Algebra continues…. ASET Rename Operation Allows us to name, and therefore to refer to, the results of relational-algebra expressions.
DATA MODELING AND DATABASE DESIGN DATA MODELING AND DATABASE DESIGN Part 2.
ASET 1 Amity School of Engineering & Technology B. Tech. (CSE/IT), III Semester Database Management Systems Jitendra Rajpurohit.
Chapter 3 The Relational Model. Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between mathematical.
SCUHolliday - coen 1789–1 Schedule Today: u Constraints, assertions, triggers u Read Sections , 7.4. Next u Embedded SQL, JDBC. u Read Sections.
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
PMIT-6102 Advanced Database Systems By- Jesmin Akhter Assistant Professor, IIT, Jahangirnagar University.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
©Silberschatz, Korth and Sudarshan6.1Database System Concepts Chapter 6: Integrity Constraints Domain Constraints Referential Integrity Assertions Triggers.
Query Languages Language in which user requests information from the database. Categories of languages Procedural Non-procedural, or declarative “Pure”
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 Constraints Ashima Wadhwa. Database Constraints Database constraints are restrictions on the contents of the database or on database operations.
CS 480: Database Systems Lecture 17 February 22, 2013.
Relational Algebra - Part 1
Chapter 2: Intro to Relational Model
Instructor: Mohamed Eltabakh
Session 2 Welcome: The seventh learning sequence
Presentation transcript:

Department of Computer Science and Engineering, HKUST Slide 1 Notation Summary R, S: table schemas such as Branch (branch-name, branch-city, assets) Account (branch-name, account-number, balance) r 1,, r 2 : table instances (i.e., sets of tuples) r 1 (R 1 ): a table instance of table schema R 1 ; e.g., r 1 (Branch) is a set of branches t 1,, t 2 : tuples A, B, C, K 1, , etc., : a set of attributes; e.g., A could represent branch- name; in the slides, we use K 1, K 2, for primary keys and  for foreign key t 1 [A]: the projection of t 1 on attribute A If r 1 is an instance of Branch and t 1 is a tupe in r 1 then t 1 [branch-name] could be “Perryridge”  K (r 1 ): the set of values under column K of table instance r 1 (note: K could consist of more than one attribute/column)

Department of Computer Science and Engineering, HKUST Slide 2 Example of Mapping ISA into Tables Employee EmpNo Name Big table: Employee(EmpNo, Name, type, payperhour, nohours, salary) PT-Emp payperhour FT-Emp salary ISA Small tables: Employee ( EmpNo, Name) PT-Emp ( EmpNo, payperhour, nohours ) FT-Emp ( EmpNo, salary ) nohours Discussion: Problem with using a big table Is it necessary to add “type” in Employee? Is it convenient to add “type” in Employee? Given an EmpNo, how do you know if he/she a PT or FT employee? Can an employee be both FT and PT? How to restrict an employee to be either FT or PT? What are the foreign keys? Do you see a problem with the definition in Slide 6?

Department of Computer Science and Engineering, HKUST Slide 3 Discussion Problem with using a big table The table will have many columns with many null values in the table Is it necessary to add “type” in Employee? Not essential; to find out the type of an employee you can check if he/she exists in the PT-EMP or FT-EMP table Does it help to add “type” in Employee? Yes, checking both tables for the type of an employee is expensive Given an EmpNo, how do you know if he/she a PT or FT employee? See above; and try to write an SQL as an exercise Can an employee be both FT and PT? Yes if nothing is done How to restrict an employee to be either FT or PT? A constraint can be specified to ensure FT and PT tables are disjoint; there are more than one way to do it

Department of Computer Science and Engineering, HKUST Slide 4 Discussion What are the foreign keys? Do you see a problem with the definition in Slide 6? EmpNo is the foreign key in PT-EMP and FT-EMP tables Yes, because on Slide 6, the definition says a foreign key in a table cannot be the primary key of that table Finally, why is Employee needed? Can we get rid of it by putting Name in the PT-Emp and FT-Emp tables? Think about it yourselves