The Relational Model1 Nulls A dilemma. The Relational Model2 The Real World Situation A common situation “Date of birth not given” “Present whereabouts.

Slides:



Advertisements
Similar presentations
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
Advertisements

Fundamentals, Design, and Implementation, 9/e COS 346 Day 8.
Relations The Relational Data Model John Sieg, UMass Lowell.
SPRING 2004CENG 3521 The Relational Model Chapter 3.
Fundamentals, Design, and Implementation, 9/e Chapter 5 Database Design.
The Relational Database Model
The Relational Database Model:
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
The Relational Model Lecture 3 Book Chapter 3 Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC) From ER to Relational.
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
The Relational Database Model. 2 Objectives How relational database model takes a logical view of data Understand how the relational model’s basic components.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 3 The Relational Database Model.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 3 The Relational Database Model.
3 1 Chapter 3 The Relational Database Model Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
CS 380 Introduction to Database Systems (Chapter 5: The Relational Data Model and Relational Database Constraints)
3 The Relational Model MIS 304 Winter Class Objectives That the relational database model takes a logical view of data That the relational model’s.
The Relational Database Model
Relational Model Session 6 Course Name: Database System Year : 2012.
Chapter 4 The Relational Model.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
CODD’s 12 RULES OF RELATIONAL DATABASE
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Relational Database Design by Relational Database Design by Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING.
Fundamentals of Relational Database Yong Choi School of Business CSUB, Bakersfield.
Lecture 7 Integrity & Veracity UFCE8K-15-M: Data Management.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
Ad Hoc Constraints Objectives of the Lecture : To consider Ad Hoc Constraints in principle; To consider Ad Hoc Constraints in SQL; To consider other aspects.
The Data in a Relation To consider atomic data in relations; To consider data types in a relation; To consider missing data & NULLs in relations. Objectives.
Natural vs. Generated Keys. Definitions Natural key—a key that occurs in the data, that uniquely identifies rows. AKA candidate key. Generated key—a key.
The Relational Database Model
1 The Relational Database Model. 2 Learning Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical.
9/7/2012ISC329 Isabelle Bichindaritz1 The Relational Database Model.
1 The Relational Model. 2 Why Study the Relational Model? v Most widely used model. – Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. v “Legacy.
FALL 2004CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
Slide Chapter 5 The Relational Data Model and Relational Database Constraints.
NULLs & Outer Joins Objectives of the Lecture : To consider the use of NULLs in SQL. To consider Outer Join Operations, and their implementation in SQL.
Module Coordinator Tan Szu Tak School of Information and Communication Technology, Politeknik Brunei Semester
Database Systems, 9th Edition 1.  In this chapter, students will learn: That the relational database model offers a logical view of data About the relational.
3 1 Chapter 3 The Relational Database Model Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Database Systems: Design, Implementation, and Management Tenth Edition Chapter 3 The Relational Database Model.
Database Systems: Design, Implementation, and Management Ninth Edition Chapter 3 The Relational Database Model.
1 CS 430 Database Theory Winter 2005 Lecture 4: Relational Model.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 3 The Relational Database Model.
Department of Mathematics Computer and Information Science1 CS 351: Database Systems Christopher I. G. Lanclos Chapter 3: The Relational Database Model.
The relational model A data model (in general) : Integrated collection of concepts for describing data (data requirements). Relational model was introduced.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Database Management Systems Chapter 5 SQL.
Dr Gordon Russell, Napier University Unit SQL 1 1 SQL 1 Unit 1.2.
3 1 Chapter 3 The Relational Database Model Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 3 The Relational Database Model.
Chapter 3 The Relational Database Model. Database Systems, 10th Edition 2 * Relational model * View data logically rather than physically * Table * Structural.
CHAPTER 2 : RELATIONAL DATA MODEL Prepared by : nbs.
1 CS 430 Database Theory Winter 2005 Lecture 7: Designing a Database Logical Level.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 3 The Relational Database Model.
Chapter 3 The Relational Model. Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between mathematical.
Quiz Which of the following is not a mandatory characteristic of a relation? Rows are not ordered (Not required) Each row is a unique There is a.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
1 CS122A: Introduction to Data Management Lecture #4 (E-R  Relational Translation) Instructor: Chen Li.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
1 Agenda TMA02 M876 Block 4. 2 Model of database development data requirements conceptual data model logical schema schema and database establishing requirements.
INFO 340 Lecture 3 Relational Databases. Based on the relational model, grounded in mathematic set theories. Three basic elements: Relation, Tuple, and.
Logical Database Design and the Rational Model
The Relational Database Model
Relational Database Design by Dr. S. Sridhar, Ph. D
Database Systems: Design, Implementation, and Management Tenth Edition
Chapter 4 Relational Model Characteristics
Lecture 2 The Relational Model
Database Systems: Design, Implementation, and Management Ninth Edition
DCT 2053 DATABASE CONCEPT Chapter 2.2 CONTINUE
INSTRUCTOR: MRS T.G. ZHOU
Presentation transcript:

The Relational Model1 Nulls A dilemma

The Relational Model2 The Real World Situation A common situation “Date of birth not given” “Present whereabouts unknown” “Date to be announced” We must handle them!

The Relational Model3 A Design Temptation Common “shortcut” Typical scenario entities A and B differ only in that A has an attribute X which B lacks create one table C, make X null for all Bs The DB is not supporting a good model code will be required in many places Tables and joins are “cheap” code is expensive (not least due to bugs)

The Relational Model4 The Theoretical Situation Nulls have challenging mathematical properties Authorities disagree on them Kroenke largely ignores them but is positive Date talks a lot about them and is violently opposed to them There is theory for them

The Relational Model5 What are Nulls - characteristics Null is not a value avoid “null value” It is the explicit absence of a value may have several real-world interpretations Different from zero bank balance example Different from “blank” defendant's reply example

The Relational Model6 Where can we have them? We will know from our requirements specification some values we must have DBMS have ways of identifying attributes like this SQL has “NOT NULL” Access has “Required”

The Relational Model7 In candidate keys? Makes no sense in real world terms Cannot uniquely identify tuple because NULL  NULL Traditionally disallowed System prevents it Compare two nulls: both attributes have real values we don’t know them can’t say they are equal

The Relational Model8 In Foreign Keys? Are traditionally allowed Can handle the employee/supervisor case CEO’s supervisor attribute is null Access allows it by default can make the attribute(s) “Required”

The Relational Model9 Left, Right and Outer Joins Explicitly generate nulls Causes some theoretical problems can cause real problems of interpretation Can be in a generated primary key

The Relational Model10 Default values Some suggest these are the better way Date Give it a “silly” value if you don’t know the real one ******! (c.f. Millenium bug) A silly value is not automatically distinguishable from a proper one Null can be properly detected others must be checked in application code must be done every time

The Relational Model11 3-valued logic The way null is often handled Scalar attribute A > B TRUE or FALSE If A or B or both are null, the answer is “UNKNOWN” ( or “UNDEFINED”) Applies to all comparison operators

The Relational Model12 Maybe We need a Maybe “all suppliers (known to be) in Singapore” + “all suppliers (known to be) not in Singapore”  “all suppliers” what about “all suppliers who may be in Singapore” ? Two-valued logic not applicable

The Relational Model13 So when should I allow them? 1) When the enterprise model has unknowns 2) When only one meaning is implied, and two-valued logic is not implicitly used

The Relational Model14 When should I disallow Nulls? Avoid NULLs when trying to represent several states, e.g. Missing value Below detection limit Value out of range Not applicable case NULLs in foreign keys? Legal, but (pto) Date is right – NULLs don’t fit into the relational model without introducing complications and inconsistencies

The Relational Model15 NULLs in foreign keys Can represent optional relationships by introducing new tables, rather than through mandatory relationships with nulls During the optimisation stage, it may be decided to relax this rule, and introduce nulls (typically when missing values occur very infrequently). “Null means no relationship” i.e. one specific meaning

The Relational Model16 Indicator Attributes The user can “extend” a domain (e.g. telephone number) to include an extra ‘Indicator’ or ‘Status’ attribute, and regard (Telephone#, Status) as a single value. Both attributes will be assigned values, always, thereby avoiding nulls. In an actual query, first test that the Status is ‘valid’ before extracting an actual telephone number.

The Relational Model17 Indicator Value Example TelStatus Valid 0000Unknown 0000Ex-directory Valid 0000No_phone Only number with Status=Valid are true phone numbers Other entries are arbitrary, but never null Status is never null