RELATIONAL DATA MODEL

Similar documents
Chapter 4. The Relational Model

Relational Data Model ( 관계형데이터모델 )

CMP-3440 Database Systems

Introduction to Relational Databases. Introduction to Relational Databases cont: Introduction to Relational Databases cont: Relational Data structure

Relational Model. Rab Nawaz Jadoon DCS. Assistant Professor. Department of Computer Science. COMSATS IIT, Abbottabad Pakistan

Chapter 3. The Relational database design

STRUCTURED QUERY LANGUAGE (SQL)

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity

CS317 File and Database Systems

CS317 File and Database Systems

Lecture 03. Spring 2018 Borough of Manhattan Community College

Chapter 2: Intro to Relational Model

Relational Algebra and Relational Calculus. Pearson Education Limited 1995,

2.2.2.Relational Database concept

8) A top-to-bottom relationship among the items in a database is established by a

Lecture 03. Fall 2017 Borough of Manhattan Community College

Chapter 5. Relational Algebra and Relational Calculus

Relational Model History. COSC 304 Introduction to Database Systems. Relational Model and Algebra. Relational Model Definitions.

1.3. Joins Introduction Access across relations Miniworld approximation Pointing mechanism

THE RELATIONAL DATABASE MODEL

ADVANCED QUERY AND VIEWS

Relational Model: History

Data about data is database Select correct option: True False Partially True None of the Above

Relational Data Model

Objective. The goal is to review material covered in Chapters 1-5. Do the following questions from the book.

Chapter 2: Intro to Relational Model

CS317 File and Database Systems

Relational Algebra and Calculus

Example 1 - Create Horizontal View. Example 2 - Create Vertical View. Views. Views

ER Model. Objectives (2/2) Electricite Du Laos (EDL) Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 1

Chapter 6 - Part II The Relational Algebra and Calculus

RELATIONAL DATA MODEL: Relational Algebra

Basant Group of Institution

Institute of Southern Punjab, Multan

Mahathma Gandhi University

Solved MCQ on fundamental of DBMS. Set-1

Relational Model, Relational Algebra, and SQL


Techno India Batanagar Computer Science and Engineering. Model Questions. Subject Name: Database Management System Subject Code: CS 601

Lecture Notes for 3 rd August Lecture topic : Introduction to Relational Model. Rishi Barua Shubham Tripathi

Fundamentals of Database Systems

3ISY402 DATABASE SYSTEMS

Introduction to Query Processing and Query Optimization Techniques. Copyright 2011 Ramez Elmasri and Shamkant Navathe

Data Models. CS552- Chapter Three

Entity Attribute STUDENT TABLE tuples single domain

Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 6 Outline. Unary Relational Operations: SELECT and

The Relational Model and Relational Algebra

Review for Exam 1 CS474 (Norton)

CS403- Database Management Systems Solved Objective Midterm Papers For Preparation of Midterm Exam

Algorithms for Query Processing and Optimization. 0. Introduction to Query Processing (1)

ECE 650 Systems Programming & Engineering. Spring 2018

Chapter 3: The Relational Database Model

Relational Algebra. Procedural language Six basic operators

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.

Comp 5311 Database Management Systems. 2. Relational Model and Algebra

Database Systems Relational Model. A.R. Hurson 323 CS Building

CMP-3440 Database Systems

Database Systems. A Practical Approach to Design, Implementation, and Management. Database Systems. Thomas Connolly Carolyn Begg

Database design process

Databases 1. Daniel POP

Fundamentals of Database Systems

QUIZ 1 REVIEW SESSION DATABASE MANAGEMENT SYSTEMS

COMP102: Introduction to Databases, 5 & 6

DB Creation with SQL DDL

Fundamentals, Design, and Implementation, 9/e Copyright 2004 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M.

II B.Sc(IT) [ BATCH] IV SEMESTER CORE: RELATIONAL DATABASE MANAGEMENT SYSTEM - 412A Multiple Choice Questions.

Chapter 2: Relational Model

UNIT 2 RELATIONAL MODEL

Database Management System 9

A subquery is a nested query inserted inside a large query Generally occurs with select, from, where Also known as inner query or inner select,

Chapter 3. Algorithms for Query Processing and Optimization

Midterm Review. Winter Lecture 13

Standard Query Language. SQL: Data Definition Transparencies

Relational Algebra Part I. CS 377: Database Systems

MIDTERM EXAMINATION Spring 2010 CS403- Database Management Systems (Session - 4) Ref No: Time: 60 min Marks: 38

File Processing Approaches

Chapter 5 Relational Algebra. Nguyen Thi Ai Thao

Slides by: Ms. Shree Jaswal

DBMS. Relational Model. Module Title?

Database System Concepts

PES Institute of Technology Bangalore South Campus (1 K.M before Electronic City,Bangalore ) Department of MCA. Solution Set - Test-II

Database Technologies. Madalina CROITORU IUT Montpellier

Chapter 3B Objectives. Relational Set Operators. Relational Set Operators. Relational Algebra Operations

Relational Model Concepts

Relational Model and Relational Algebra. Rose-Hulman Institute of Technology Curt Clifton

CS403- Database Management Systems Solved MCQS From Midterm Papers. CS403- Database Management Systems MIDTERM EXAMINATION - Spring 2010

Index. Bitmap Heap Scan, 156 Bitmap Index Scan, 156. Rahul Batra 2018 R. Batra, SQL Primer,

Principles of Data Management

Chapter 19 Query Optimization

Assignment Session : July-March

Running Example Tables name location

Chapter 17. Methodology Logical Database Design for the Relational Model

DATABASE MANAGEMENT SYSTEM

King Fahd University of Petroleum and Minerals

Ian Kenny. November 28, 2017

Relational Algebra. Relational Algebra. 7/4/2017 Md. Golam Moazzam, Dept. of CSE, JU

Faloutsos - Pavlo CMU SCS /615

Overview. Carnegie Mellon Univ. School of Computer Science /615 - DB Applications. Concepts - reminder. History

Informationslogistik Unit 4: The Relational Algebra

DATABASE MANAGEMENT SYSTEM SHORT QUESTIONS. QUESTION 1: What is database?

Transcription:

RELATIONAL DATA MODEL EGCO321 DATABASE SYSTEMS KANAT POOLSAWASD DEPARTMENT OF COMPUTER ENGINEERING MAHIDOL UNIVERSITY

RELATIONAL DATA STRUCTURE (1) Relation: A relation is a table with columns and rows. Attribute: An attribute is a named column of a relation. Domain: A domain is the set of allowable values for one or more attributes. Tuple: A tuple is a row of a relation. Cardinality: The cardinality of a relation is the number of tuples it contains. Relational Database: A collection of normalized relations with distinct relation names.

RELATIONAL DATA STRUCTURE (2)

RELATIONAL DATA STRUCTURE (3)

ALTERNATIVE TERMINOLOGY

DATABASE RELATIONS Relation Schema: A named relation defined by a set of attribute and domain name pairs. schema Relational Database Schema: A set of relation schemas, each with a distinct name.

PROPERTIES OF RELATIONS (1) The relation has a name that is distinct from all other relation names in the relational schema. Each cell of the relation contains exactly one atomic (single) value; n each attribute has a distinct name. The values of an attribute are all from the same domain. Each tuple is distinct; there are no duplicate tuples. The order of attributes has no significance. The order of tuples has no significance, theoretically. (However, in practice, the order may affect the efficiency of accessing tuples.)

PROPERTIES OF RELATIONS (2)

RELATIONAL KEYS Super Key: a column or combination of columns containing unique value for each row. Candidate Key: a minimal super key. A super key is minimal if removing any column makes it no longer unique. Null Value: a special value that represents the absence of an actual value. A null value can mean that the actual value is unknown or does not apply to the given row. Primary Key: a specially designated candidate key. The primary key for a table cannot contain null value. Foreign Key: a column or combination of columns in which the values must match those of a candidate key. A foreign key must have the same data type as its associated candidate key

INTEGRITY RULES (1) Entity Integrity means that each table must have a column or combination of columns with unique values. Unique means that no two rows of a table have the same value. Referential Integrity means that the column values in one table must match column values in a related table.

INTEGRITY RULES (2) Entity Integrity Rule: No two rows of a table can contain the same value for the primary key. In addition, no row can contain a null value for any column of a primary key. Referential Integrity Rule: Only two kinds of values can be stored in a foreign key: A value matching a candidate key value in some row of the table containing the associated candidate key. A null value.

RELATIONSHIP Self-Referencing Relationship is a relationship in which a foreign key refers to the same table. Self-referencing relationships represent associations among members of the same set. 1-M Relationship is a connection between two table in which one row of a parent table can be referenced by many rows of a child table. 1-M relationships are the most common kind of relationship. M-N Relationship is a connection between two table in which rows of each table can be related to many rows of the other table. M-N relationships cannot be directly represented in the Relationship Model. Two 1-M relationships and a linking or associative table represent an M-N relationship.

RELATIONAL ALGEBRA (1)

RELATIONAL ALGEBRA (2)

RELATIONAL ALGEBRA (3)

RELATIONAL ALGEBRA (4)

SAMPLE DATA (1)

SAMPLE DATA (2)

EXAMPLE 1 (SELECTION) List all staff with a salary grater than 10,000

EXAMPLE 2 (PROJECTION) Produce a list of salary for all staff, showing only the staffno, fname, lname, and salary detail.

EXAMPLE 3 (PRODUCT) (1)

EXAMPLE 3 (PRODUCT) (2)

JOIN OPERATIONS Typically, we want only combinations of the Cartesian product that satisfy certain condi- tions and so we would normally use a Join operation instead of the Cartesian product operation. Type of join operations Theta join Equijoin (a particular type of theta join) Natural join Outer join Semi join

EXAMPLE 4 (JOIN) List the names and comments of all clients who have viewed a property for rent.

EXAMPLE 5 (OUTER JOIN) Produce a status report on property viewings.

EXAMPLE 6 (SEMI JOIN) List complete details of all staff who at the branch in Glasgow.

AGGREGATION AND GROUPING OPERATIONS As well as simply retrieving certain tuples and attributes of one or more relations, we often want to perform some form of summation or aggregation of data, similar to the totals at the bottom of a report, or some form of grouping of data, similar to subtotals in a report. The main aggregation function are: COUNT SUM AVG MIN MAX

EXAMPLE 7 (AGGREGATION) How many properties cost more than 350 per month to rent? Find the minimum, maximum, and average staff salary.

EXAMPLE 8 (GROUPING) Find the number of staff working in each branch and the sum of their salaries.

TUPLE RELATIONAL CALCULUS In the tuple relational calculus we are interested in finding tuples for which a predicate is true. The calculus is based on the use of tuple variables. A tuple variable is a variable that ranges over a named relation: that is, a variable whose only permitted values are tuples of the relation. For example: List the names of all managers who earn more than 25,000. List the staff who manage properties for rent in Glasgow.

ASSIGNMENT 1 (1) Use the database show in this figure to answer problem.

ASSIGNMENT 1 (2) For each table, identify the primary key and the foreign key(s). If a table does not have a foreign key, write None in the assigned space.

ASSIGNMENT 1 (3) Do the tables exhibit entity integrity? Answer Yes or No, the explain your answer.

ASSIGNMENT 1 (4) Do the tables exhibit referential integrity? Answer Yes or No, the explain your answer. Write N/A (Not Applicable) if the table does not have a foreign key.