Chapter 4 Rational data model. Chapter 5 Rational data model Chapter 4 Rational data model.

Slides:



Advertisements
Similar presentations
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 5 The Relational Data Model and Relational Database Constraints.
Advertisements

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Basic (Flat) Relational Model.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 5- 1.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 5- 1.
Chapter 5 The Relational Data Model and Relational Database Constraints Copyright © 2004 Pearson Education, Inc.
Database Systems Chapter 5 ITM 354. Chapter Outline Relational Model Concepts Relational Model Constraints and Relational Database Schemas Update Operations.
Chapter 5 The Relational Data Model and Relational Database Constraints.
CS 405G: Introduction to Database Systems Lecture 4: Relational Model Instructor: Chen Qian.
Database Systems Relational Model Concepts Toqir Ahmad Rana Database Management Systems 1 Lecture 17.
Chapter 5 Relational Model Concepts Dr. Bernard Chen Ph.D. University of Central Arkansas.
CS 380 Introduction to Database Systems (Chapter 5: The Relational Data Model and Relational Database Constraints)
1 Relational model concepts Key constraints Referential integrity constraint Steen Jensen, autumn 2013.
The Relational Data Model 1.Relational Model Concepts 2.Characteristics of Relations 3.Relational Integrity Constraints 3.1Key Constraints 3.2Entity Integrity.
1 The Relational Data Model, Relational Constraints, and The Relational Algebra.
Content Resource- Elamsari and Navathe, Fundamentals of Database Management systems.
CG084&085 / / 1 The Relational Data Model Properties of Relations Keys and Constraints.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Relational Data Model and SQL.
Topic 5 The Relational Data Model and Relational Database Constraints Faculty of Information Science and Technology Mahanakorn University of Technology.
Instructor: Churee Techawut Basic Concepts of Relational Database Chapter 5 CS (204)321 Database System I.
DatabaseIM ISU1 Fundamentals of Database Systems Chapter 5 The Relational Data Model.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 5- 1.
The Relational Data Model and Relational Database Constraints
10/9/20151 The Relational Data Model TCU Database Systems Last update: September 2004 Reference: Elmasri 4 th edition, chapter 5.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 5- 1 Week4 Relational Model and Relational Database Constraints Relational Model Concepts.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 5- 1.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 5 The Relational Data Model and Relational Database Constraints.
1 CSE 480: Database Systems Lecture 5: Relational Data Model.
METU Department of Computer Eng Ceng 302 Introduction to DBMS The Relational Data Model and Relational Database Constraints by Pinar Senkul resources:
Ihr Logo Fundamentals of Database Systems Fourth Edition El Masri & Navathe Chapter 5 The Relational Data Model and Relational Database Constraints.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 5 The Relational Data Model and Relational Database Constraints.
Chapter 6 The Relational Data Model and the Relational Algebra.
1 The Relational Model. 2 Why Study the Relational Model? v Most widely used model. – Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. v “Legacy.
Relational Data Model Ch. 7.1 – 7.3 John Ortiz Lecture 3Relational Data Model2 Why Study Relational Model?  Most widely used model.  Vendors: IBM,
Slide Chapter 5 The Relational Data Model and Relational Database Constraints.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 3 The Basic Relational Model.
CSE314 Database Systems Lecture 3 The Relational Data Model and Relational Database Constraints Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 5- 1.
Instructor: Jinze Liu Fall Phases of Database Design u Conceptual design begins with the collection of requirements and results needed from the.
Relational Data Model DeSiaMore Powered by DeSiaMore.
Chapter 5 The Relational Data Model and Relational Database Constraints Copyright © 2004 Pearson Education, Inc.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe CHAPTER 5 The Relational Data Model and Relational Database Constraints Slide 1- 1.
The Relational Data Model and Relational Database Constraints
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 5- 1.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 5- 1.
The Relational Data Model and Relational Database Constraints.
4/28/2017 Chapter 5 The Relational Data Model and Relational Database Constraints.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Relational Data Model and Relational Database Constraints تنبيه.
Lecture # 11 & 12 (First Exam) Chapter # 5 The Relational Data Model and Relational Database Constraints Database Systems.
Copyright © 2004 Pearson Education, Inc.
4/20/2018.
Lecture # 13 (After 1st Exam)
Constraints AND Examples
The Relational Data Model
The Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database Constraints
CS4222 Principles of Database System
12/7/2018.
The Relational Data Model and Relational Database Constraints
2/28/2019 Chapter 5 The Relational Data Model and Relational Database Constraints.
4/8/2019.
The Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database Constraints
5/12/2019.
Constraints AND Examples
Copyright © 2004 Pearson Education, Inc.
The Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database Constraints
Presentation transcript:

Chapter 4 Rational data model

Chapter 5 Rational data model Chapter 4 Rational data model

Contents Relational Model Concepts Relational Model Constraints and Relational Database Schemas

The things you should know… The relational Model of Data is based on the concept of a Relation. The basic principle of relational database is proposed by E.F.Codd in The first RDBMS production is System R The most popular RDBMS DB2, Oracle, Ingres, Sybase, Informix,…

Informal Definitions RELATION: A table of values  A relation may be thought of as a set of rows.  Each row represents a fact that corresponds to a real- world entity or relationship.  Each row has a value of an item or set of items that uniquely identifies that row in the table.  Each column typically is called by its column name or column header or attribute name.

Informal Definitions Key of a Relation:  Each row has a value of a data item (or set of items) that uniquely identifies that row in the table Called the key  In the STUDENT table, SSN is the key  Sometimes row-ids or sequential numbers are assigned as keys to identify the rows in a table Called artificial key

Example - Figure 5.1

Basic of the Relational Model The relational model gives us a single way to represent data: as a two- dimensional table called a relation.

Attributes ( 属性 )  Attributes of a relation serve us as names for the columns of the relation.  Usually, the attributes describes the meaning of entites in the column below.

Schemas (模式)  The name of a relation and the set of attributes for a relation is called the schema for that relation.  We show the schema for the relation with the relation name followed by a parenthesized list of its attributes.

Tuples (元组)  The rows of a relation, other than the header row containing the attributes, are called tuple. For example:  Relations, however, are sets of tuples, and it is impossible for a tuple to appear more than once in a given relation.

Domains (域)  The relational model requires that each component of each tuple be atomic; that is, it must be of some elementary type such as integers or string.  Each attributes of a relation has particular elementary type, thus domain is decided.

Formal Definitions A domain has a logical definition. Example: “USA_phone_numbers” are the set of 10 digit phone numbers valid in the U.S. A domain also has a data-type or a format defined for it.  For example, the USA_phone_numbers may have a format: (ddd)-ddd-dddd where each d is a decimal digit.  Dates have various formats such as month, date, year or yyyy-mm-dd, or dd mm,yyyy etc.

Equivalent Representations of a Relation  The attributes of the relation can be reordered without change the relation.

Relation Instance (关系实例)  A relation about movies is not static; rather, relations change over time.  It is not common for the schema of a relation to change.  We shall call a set of tuples for a given relation an instance of that relation.

DEFINITION SUMMARY Informal TermsFormal Terms TableRelation ColumnAttribute/Domain RowTuple Values in a columnDomain Table DefinitionSchema of a Relation Populated TableExtension

An Example of Relation Instance Relation: Person (Name, Address, Telephone) Relation Instance: NameAddressTelephone Bob123 Main St Bob128 Main St Pat123 Main St Harry456 Main St Sally456 Main St Sally456 Main St Pat12 State St

More … Relation (Instance) = a set of tuples Database = collection of relations Relation schema = relation name + attributes  Example: Movies (title, year, length, fileType) Database schema = a set of all relation schemas  Movies(Title, Year, Length, FileType)  Star(Name, Age)  Studio(StudioName, Addr)

Name Addr Tel N1 A1 T1 N2 A2 T2 N3 A3 T3 N4 T4 N5 T5 T6 T7 Name Addr Tel N1 A1 T1 N1 A1 T2 N1 A1 T3. N1 A1 T7 N1 A2 T1 N1 A3 T1 N2 A1 T1 Tuple Domai n Component Attribute

Characteristics of Relations Ordering of tuples in a relation r(R):  The tuples are not considered to be ordered, even though they appear to be in the tabular form. Ordering of attributes in a relation schema R (and of values within each tuple):  We will consider the attributes in R(A 1, A 2,..., A n ) and the values in t= not to be ordered. Values in a tuple: All values are considered atomic (indivisible). A special null value is used to represent values that are unknown or inapplicable to certain tuples.

Chapter 5-22 Key Example: The STUDENT relation schema: STUDENT(stu_num, stu_name, gender, major, Year) has two keys Key1 = {stu_num}, Key2 = {stu_name} candidate keys:just keys If a relation has several candidate keys, one is chosen arbitrarily to be the primary key. The primary key attributes are underlined.

Relational Integrity Constraints Constraints are conditions that must hold on all valid relation states. There are three main types of constraints in the relational model:  Entity integrity constraints  Referential integrity constraints  User-define Constraints  Users define the constrains themselves Another implicit constraint is the domain constraint  Every value in a tuple must be from the domain of its attribute (or it could be null, if allowed for that attribute)

Chapter 5-24 Entity Integrity Entity Integrity: The primary key attributes PK of each relation schema R in S cannot have null values in any tuple of r(R)and have different values. This is because primary key values are used to identify the individual tuples.

Entity integrity i.e : student ( stu_num , name , gender , age,major_num ) course ( course_num , curse_name , teacher ) select_course ( stu_num , course_num , grades )

Chapter 5-26 Referential Integrity A constraint involving two relations (the previous constraints involve a single relation). Used to specify a relationship among tuples in two relations: the referencing relation and the referenced relation. Tuples in the referencing relation R 1 have attributes FK (called foreign key attributes) that reference the primary key attributes PK of the referenced relation R 2. A tuple t 1 in R 1 is said to reference a tuple t 2 in R 2 if t 1 [FK] = t 2 [PK].

Chapter 5-27 Referential Integrity Constraint Statement of the constraint The value in the foreign key column (or columns) FK of the the referencing relation R 1 can be either: (1) a value of an existing primary key value of the corresponding primary key PK in the referenced relation R 2,, or.. (2) a null. In case (2), the FK in R 1 should not be a part of its own primary key.

i.e 1: student ( stu_num , name , gender , age,major_num ) major ( major_num , major_name ) Fore ign key Referen cing relation Referenc ed relation student major Major_num

Chapter 5-29 Other Types of Constraints Constraints: - based on application semantics and cannot be expressed by the model. - E.g., “the max. no. of hours per employee for all projects he or she works on is 56 hrs per week” - A constraint specification language may have to be used to express these - SQL-99 allows triggers and ASSERTIONS to allow for some of these

Chapter 5-30

Chapter

Chapter