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

Similar documents
CMP-3440 Database Systems

Chapter 4. The Relational Model

CS317 File and Database Systems

RELATIONAL DATA MODEL

Relational Algebra and Relational Calculus. Pearson Education Limited 1995,

Chapter 3. The Relational database design

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

CS317 File and Database Systems

Lecture 03. Spring 2018 Borough of Manhattan Community College

Lecture 03. Fall 2017 Borough of Manhattan Community College

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

CS317 File and Database Systems

Chapter 5. Relational Algebra and Relational Calculus

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

Database Technologies. Madalina CROITORU IUT Montpellier

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

2.2.2.Relational Database concept

3ISY402 DATABASE SYSTEMS

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

Chapter 3: The Relational Database Model

STRUCTURED QUERY LANGUAGE (SQL)

RELATIONAL DATA MODEL: Relational Algebra

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

THE RELATIONAL DATABASE MODEL

Chapter 2: Intro to Relational Model

DB Creation with SQL DDL

Entity Attribute STUDENT TABLE tuples single domain

Review for Exam 1 CS474 (Norton)

Fundamentals of Database Systems

Running Example Tables name location

Midterm Review. Winter Lecture 13

Chapter 6. SQL: SubQueries

Chapter 2 Introduction to Relational Models

Basant Group of Institution

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

Mahathma Gandhi University

Databases 1. Daniel POP

CS 377 Database Systems

Data Models. CS552- Chapter Three

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

Chapter 2: Intro to Relational Model

Chapter 6. SQL Data Manipulation

The data structures of the relational model Attributes and domains Relation schemas and database schemas

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

CMP-3440 Database Systems

Relational Algebra and Calculus

Lecture 07. Spring 2018 Borough of Manhattan Community College

Relational Data Model

Chapter 6 The Relational Algebra and Calculus

Relational Database: The Relational Data Model; Operations on Database Relations

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

Relational Algebra Part I. CS 377: Database Systems

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

Transforming ER to Relational Schema

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

Relational Model: History

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

Ian Kenny. November 28, 2017

ECE 650 Systems Programming & Engineering. Spring 2018

Relational Database Model. III. Introduction to the Relational Database Model. Relational Database Model. Relational Terminology.

Chapter 6 The Relational Algebra and Relational Calculus

UNIT 2 RELATIONAL MODEL

Chapter 2: Relational Model

CS121 MIDTERM REVIEW. CS121: Relational Databases Fall 2017 Lecture 13

Relational Databases

Chapter 5 Relational Algebra. Nguyen Thi Ai Thao

Institute of Southern Punjab, Multan

Relational Query Languages: Relational Algebra. Juliana Freire

Chapter 6 - Part II The Relational Algebra and Calculus

Database System Concepts, 5 th Ed.! Silberschatz, Korth and Sudarshan See for conditions on re-use "

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

Database System Concepts

Relational Model, Relational Algebra, and SQL

Lecture 6 Structured Query Language (SQL)

Supplier-Parts-DB SNUM SNAME STATUS CITY S1 Smith 20 London S2 Jones 10 Paris S3 Blake 30 Paris S4 Clark 20 London S5 Adams 30 Athens

A7-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS

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

Relational Algebra. ICOM 5016 Database Systems. Roadmap. R.A. Operators. Selection. Example: Selection. Relational Algebra. Fundamental Property

Database Technologies. Madalina CROITORU IUT Montpellier

A database can be modeled as: + a collection of entities, + a set of relationships among entities.

1.3. Joins Introduction Access across relations Miniworld approximation Pointing mechanism

Querying Data with Transact SQL

The Relational Model and Relational Algebra

CPS 510 Data Base I. There are 3 forms of database descriptions the ANSI/SPARK, 1975 and so on

Lecture 5 Data Definition Language (DDL)

DATABASE DESIGN I - 1DL300

The Relational Algebra

CS2300: File Structures and Introduction to Database Systems

Chapter 8: The Relational Algebra and The Relational Calculus

What is an algebra? A formal system of manipulation of symbols to deal with general statements of relations.

Database Management System 9

UNIT- II (Relational Data Model & Introduction to SQL)

Database Technologies. Madalina CROITORU IUT Montpellier

Informationslogistik Unit 4: The Relational Algebra

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

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

Chapter 6 5/2/2008. Chapter Outline. Database State for COMPANY. The Relational Algebra and Calculus

Relational Query Languages. Preliminaries. Formal Relational Query Languages. Example Schema, with table contents. Relational Algebra

Standard Query Language. SQL: Data Definition Transparencies

Applied Databases. Sebastian Maneth. Lecture 5 ER Model, normal forms. University of Edinburgh - January 25 th, 2016

Transcription:

Relational Data Model ( 관계형데이터모델 ) Outline Terminology of Relational Model Mathematical Relations and Database Tables Candidate, Primary, and Foreign Keys

Terminology in the Relational Model Relation: A table with columns and rows. Attribute: A named column of a relation. Domain: The set of allowable values for one or more attributes. Tuple: A row of a relation. Degree: The number of attributes in a relation. Cardinality: The number of tuples in a relation. Primary Key Foreign Key Relational Database is a collection of normalized relations with distinct relation names. Examples of Attribute Domains

Alternative Terminology for Relational Model Mathematical Definition of Relation Consider two sets, D 1 and D 2, where D 1 = {2, 4} and D 2 = {1, 3, 5}. D 1 D 2 = {(2, 1), (2, 3), (2, 5), (4, 1), (4, 3), (4, 5)} Any subset of Cartesian product is a relation; e.g. R = {(2, 1), (4, 1)} May specify which pairs are in relation using some condition for selection; The second element is 1: R = {(x, y) x D 1, y D 2, and y = 1} The first element is always twice the second: S = {(x, y) x D 1, y D 2, and x = 2y} Consider three sets D 1, D 2, D 3 with Cartesian Product D 1 D 2 D 3 ; e.g. D 1 = {1, 3}, D 2 = {2, 4}, D 3 = {5, 6} D 1 D 2 D 3 = {(1,2,5), (1,2,6), (1,4,5), (1,4,6), (3,2,5), (3,2,6), (3,4,5), (3,4,6)} Any subset of these ordered triples is a relation.

Relation Example Source = {GenBank, Swissprot, PDB, RefSeq, MOCA} Manager = {KAIST, NCBI, SIB, RCSB} Source Manager = {(G, K), (G, N), (G, S), (G, R), (S, K), (S, N), (S, S), (S, R), (P, K), (P, N), (P, S), (P, R), (R, K), (R, N), (R, S), (R, R), (M, K), (M, N), (M, S), (M, R)} A Relation DBM = {(GenBank, NCBI), (SwissProt, SIB), (PDB, RCSB), (RefSeq, NCBI), (MOCA, KAIST) } Source Manager Database Relations Relation schema (cf. scheme) Named relation defined by a set of attribute and domain name pairs. Relational database schema Set of relation schemas, each with a distinct name. Properties of database relations Relation names are distinct in a relational schema. Each attribute has a distinct name within a relation. Each cell of relation contains exactly one atomic (single) value. Values of an attribute are all from the same domain. Each tuple is distinct; there are no duplicate tuples. Order of attributes has no significance. Order of tuples has no significance, theoretically.

Relational Keys Superkey An attribute, or a set of attributes, that uniquely identifies a tuple within a relation. Candidate Key Superkey (K) such that no proper subset is a superkey within the relation. In each tuple of R, values of K uniquely identify that tuple (uniqueness). No proper subset of K has the uniqueness property (irreducibility). = minimality Primary Key Candidate key selected to identify tuples uniquely within relation. (=> commonly implies the physical order) Alternate Keys Candidate keys that are not selected to be primary key. Foreign Key Attribute, or set of attributes, within one relation that matches candidate key of some (possibly same) relation. Relational Keys - Example Protein = (Accession, Name, Description, AASeq, Length, GI, Type) SCOP = (Class, Description, Alpha, Beta, Loop, Property) Candidate Keys of Protein Accession, GI, (AASeq) Primary Key: Accession, Alternate Keys: GI, (AASeq) Foreign Key of Protein w.r.t SCOP: Type (Protein.Type => SCOP.Class) Super Keys: Any supersets of candidate keys E.g. {Accession, Name}, {GI, Accession} Cf. HighSchoolStudent = (Year, Class, Num, Name, Address, Teacher) Primary Key = {Year, Class, Num}

Relational Integrity Null Represents value for an attribute that is currently unknown or not applicable for tuple. Deals with incomplete or exceptional data. Represents the absence of a value and is not the same as zero or spaces, which are values. Entity Integrity In a base relation, no attribute of a primary key can be null. Referential Integrity If foreign key exists in a relation, either foreign key value must match a candidate key value of some tuples in its home relation or foreign key value must be wholly null. Enterprise Constraints Additional rules specified by users or database administrators. Data Languages Abstract mathematical model = passive part + active part Data Type = Data + Operations e.g.: 3 + 4 = 7 vs. 3 + 4 = 34 e.g.: area(box) = height x width, area(circle) = x radius 2 Data Model = Data Organization + Data Languages Relational Data Model Data Organization: relations Data Languages: relational algebra and relational calculus Relational DBMS Data Organizations: tables Data Languages: SQL (relationally complete)

Relational Algebra Algebra: operands (data holders) and operators (data transformers) What operations are necessary for dealing with relations Insert, Search, Update, Delete Five basic operations Selection, Projection, Cartesian product, Union, and Set Difference. These perform most of the data search operations. cf. Assignment Also have Join, Intersection, and Division operations, which can be expressed in terms of the five basic operations. Closure property of relational model Relational algebra operations work on one or more relations to define another relation without changing the original relations. Both operands and results are relations, so output from one operation can become input to another operation. Allows expressions to be nested, just as in arithmetic. Relational Algebra Operations Non-basic

Relational Algebra Operations (Extended) Selection (or Restriction) predicate (R) Works on a single relation R and defines a relation that contains only those tuples (rows) of R that satisfy the specified condition (predicate). List all staff with a salary greater than 10,000. salary > 10000 (Staff)

Projection col1,..., coln (R) Works on a single relation R and defines a relation that contains a vertical subset of R, extracting the values of specified attributes and eliminating duplicates. Produce a list of salaries for all staff, showing only staffno, fname, lname, and salary details. staffno, fname, lname, salary (Staff) Union R S Union of two relations R and S defines a relation that contains all the tuples of R, or S, or both R and S, duplicate tuples being eliminated. R and S must be union-compatible. If R and S have I and J tuples, respectively, union is obtained by concatenating them into one relation with a maximum of (I + J) tuples. List all cities where there is either a branch office or a property for rent. city (Branch) city (PropertyForRent)

Set Difference R S Defines a relation consisting of the tuples that are in relation R, but not in S. R and S must be union-compatible. List all cities where there is a branch office but no properties for rent. city (Branch) city (PropertyForRent) Intersection R S Defines a relation consisting of the set of all tuples that are in both R and S. R and S must be union-compatible. Expressed using basic operations: R S = R (R S) List all cities where there is both a branch office and at least one property for rent. city (Branch) city (PropertyForRent)

Cartesian Product cf. Rene Descartes (Renatus Cartesius) R X S Defines a relation that is the concatenation of every tuple of relation R with every tuple of relation S. List the names and comments of all clients who have viewed a property for rent. ( clientno, fname, lname (Client)) X ( clientno, propertyno, comment (Viewing)) Cartesian Product and Selection Use selection operation to extract those tuples where Client.clientNo = Viewing.clientNo. Client.clientNo = Viewing.clientNo (( clientno, fname, lname (Client)) ( clientno, propertyno, comment (Viewing))) Cartesian product and Selection can be reduced to a single operation called a Join.

Join Operations Join is a derivative of Cartesian product. Equivalent to performing a Selection, using join predicate as selection formula, over Cartesian product of the two operand relations. One of the most difficult operations to implement efficiently in an RDBMS and one reason why RDBMSs have intrinsic performance problems. Various forms of join operation Theta join Equijoin (a particular type of Theta join) Natural join Outer join Semijoin Natural Join R S An Equijoin of the two relations R and S over all common attributes x. One occurrence of each common attribute is eliminated from the result. List the names and comments of all clients who have viewed a property for rent. ( clientno, fname, lname (Client)) ( clientno, propertyno, comment (Viewing))

Outer Join To display rows in the result that do not have matching values in the join column, use Outer join. R S (Left) outer join is join in which tuples from R that do not have matching values in common columns of S are also included in result relation. Produce a status report on property viewings. propertyno, street, city (PropertyForRent) Viewing Division R S Defines a relation over the attributes C that consists of set of tuples from R that match combination of every tuple in S. Expressed using basic operations: T 1 C (R) T 2 C ((S X T 1 ) R) T T 1 T 2 Identify all clients who have viewed all properties with three rooms. ( clientno, propertyno (Viewing)) ( propertyno ( rooms = 3 (PropertyForRent)))

Summary Terminology of Relational Model Mathematical Relations and Database Tables Candidate, Primary, and Foreign Keys Data languages and algebra Fundamental algebra operations Extended algebra operations