1.1 - Relational Database Concepts1
-
Upload
rickz-huang -
Category
Documents
-
view
23 -
download
1
description
Transcript of 1.1 - Relational Database Concepts1
![Page 1: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/1.jpg)
1 © 2011 IBM Corporation
Relational Database Concepts
IBM Information Management Cloud Computing Center of CompetenceIBM Canada Labs
![Page 2: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/2.jpg)
2 © 2011 IBM Corporation
• Overview
• Information and Data Models
• The relational model• Entity-Relationship diagrams• Types of relationships• Mapping entities to tables• Relational model concepts• Relational model constraints• Normalization
Agenda
![Page 3: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/3.jpg)
3 © 2011 IBM Corporation
• Reading materials• Database Fundamentals eBook
• Chapter 1: Databases and information models• Chapter 2: The relational data model• Chapter 3: The conceptual data model (optional)• Chapter 4: Relational database design (optional)
• Videos• db2university.com course AA001EN
• Lesson 1: Relational database concepts
Supporting reading material & videos
![Page 4: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/4.jpg)
4 © 2011 IBM Corporation
• Overview
• Information and Data Models
• The relational model• Entity-Relationship diagrams• Types of relationships• Mapping entities to tables• Relational model concepts• Relational model constraints• Normalization
Agenda
![Page 5: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/5.jpg)
5 © 2011 IBM Corporation
Data vs. Information
• Data: Collection of letters, numbers or facts
• Information: Processed data that provides value
![Page 6: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/6.jpg)
6 © 2011 IBM Corporation
Databases and DBMS• Databases
• A repository of data
• DBMS (Database management system)• Software system that manages databases
• The terms “Database”, “DBMS”, “data server”, “database server” often used interchangeably to refer to a DBMS
• Why a DBMS?• Security
• Can handle many users with good performance
• Allows for concurrency while keeping data consistent
• Protects from disaster
![Page 7: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/7.jpg)
7 © 2011 IBM Corporation
• Overview
• Information and Data Models
• The relational model• Entity-Relationship diagrams• Types of relationships• Mapping entities to tables• Relational model concepts• Relational model constraints• Normalization
Agenda
![Page 8: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/8.jpg)
8 © 2011 IBM Corporation
Information and Data Models
Relationship between an Information Model and a Data Model
![Page 9: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/9.jpg)
9 © 2011 IBM Corporation
Data Models
• Network
• Hierarchical
• Relational
• Entity-Relationship
• Extended relational
• Semantic
• Object-oriented
• Object-relational
• Semi-structured
![Page 10: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/10.jpg)
10 © 2011 IBM Corporation
• Overview
• Information and Data Models
• The relational model• Entity-Relationship diagrams• Types of relationships• Mapping entities to tables• Relational model concepts• Relational model constraints• Normalization
Agenda
![Page 11: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/11.jpg)
11 © 2011 IBM Corporation
Relational Model
![Page 12: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/12.jpg)
12 © 2011 IBM Corporation
Entity-Relationship Diagrams
• Building Blocks
• Entities
• Attributes
Entity
Attribute
![Page 13: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/13.jpg)
13 © 2011 IBM Corporation
Entity and Attributes
![Page 14: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/14.jpg)
14 © 2011 IBM Corporation
ER diagram
Book
Title
ISBN
Editon
Year
PricePages
Aisle
Description
![Page 15: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/15.jpg)
15 © 2011 IBM Corporation
Exercise: Identify entities and attributes
House
Date
ComputerSocial Security Number
Height Order #
Product
Phone #
![Page 16: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/16.jpg)
16 © 2011 IBM Corporation
Did you get them right?
House
Date
ComputerSocial Security Number
Height Order #
Product
Phone #
![Page 17: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/17.jpg)
17 © 2011 IBM Corporation
• Overview
• Entity-relationship diagrams
• The relational model• Entity-Relationship diagrams• Types of relationships• Mapping entities to tables• Relational model concepts• Relational model constraints• Normalization
Agenda
![Page 18: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/18.jpg)
18 © 2011 IBM Corporation
Relationships
• Building Blocks
– Entity sets
– Relationship sets
– Crows Foot notations
![Page 19: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/19.jpg)
19 © 2011 IBM Corporation
ERD of Book
Book
Title
ISBN
Editon
Year
PricePages
Aisle
Description
![Page 20: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/20.jpg)
20 © 2011 IBM Corporation
ERD of Author
Author
Author_Id
City
Lastname
Firstname
Country
![Page 21: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/21.jpg)
21 © 2011 IBM Corporation
Example 1
![Page 22: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/22.jpg)
22 © 2011 IBM Corporation
Example 2
![Page 23: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/23.jpg)
23 © 2011 IBM Corporation
One-to-one Relationship
Book AuthorAuthored By
Types of Relationships
![Page 24: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/24.jpg)
24 © 2011 IBM Corporation
One-to-many Relationships
Book AuthorAuthored By
Types of Relationships (Continued)
![Page 25: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/25.jpg)
25 © 2011 IBM Corporation
Many-to-many Relationships
Book AuthorAuthored By
Types of Relationships (Continued)
![Page 26: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/26.jpg)
26 © 2011 IBM Corporation
• Overview
• Entity-relationship diagrams
• The relational model• Entity-Relationship diagrams• Types of relationships• Mapping entities to tables• Relational model concepts• Relational model constraints• Normalization
Agenda
![Page 27: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/27.jpg)
27 © 2011 IBM Corporation
ERD revisited
Book
Title
ISBN
Editon
Year
PricePages
Aisle
Description
![Page 28: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/28.jpg)
28 © 2011 IBM Corporation
Mapping entity to a table
Entity
Table
Book
Title
ISBN
Editon
Year
PricePages
Aisle
Description
Attributes
Columns
![Page 29: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/29.jpg)
29 © 2011 IBM Corporation
Mapping entity to a table (Continued)
Title Edition Year Price ISBN Pages Aisle Description
Database Fundamentals
1 2010 24.99 978-0-9866283-1-1
300 DB-A02
Teaches you the fundamentals of databases
Getting started with DB2 Express-C
1 2010 24.99 978-0-9866283-5-1
280 DB-A01
Teaches you the essentials of DB2 using DB2 Express-C, the free version of DB2
Table: Book
![Page 30: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/30.jpg)
30 © 2011 IBM Corporation
Mapping entity to a table (Continued)
Author_ID Lastname Firstname Email City Country
A1 Chong Raul [email protected] Toronto CA
A2 Ahuja Rav [email protected] Toronto CA
A3 Hakes Ian [email protected] Toronto CA
A4 Sharma Neeraj [email protected] Chennai IN
A5 Perniu Liviu [email protected] Transilvania
RO
Table: Author
![Page 31: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/31.jpg)
31 © 2011 IBM Corporation
• Overview
• Entity-relationship diagrams
• The relational model• Entity-Relationship diagrams• Types of relationships• Mapping entities to tables• Relational model concepts• Relational model constraints• Normalization
Agenda
![Page 32: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/32.jpg)
32 © 2011 IBM Corporation
Relational Model Concepts
• Building Blocks
• Relation
• Sets
Dr. E.F. Codd of IBM in 1970: “A Relational Model for Large Shared Data Banks”
![Page 33: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/33.jpg)
33 © 2011 IBM Corporation
A Relational Database
•Relational Database
• Relation
• Relation Schema
• Relation Instance
![Page 34: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/34.jpg)
34 © 2011 IBM Corporation
A Relation
Author_ID
Lastname Firstname
Email City Country
A1 Chong Raul [email protected] Toronto CA
A2 Ahuja Rav [email protected] Toronto CA
A3 Hakes Ian [email protected] Toronto CA
A4 Sharma Neeraj [email protected] Chennai IN
A5 Perniu Liviu [email protected] Transilvania RO
TUPLES
ATTRIBUTES
DEGREE=6CARDINALITY=5
AUTHOR(Author_ID: char, lastname: varchar, firstname: varchar, email: varchar, city: varchar, country: char)
Relation Schema
Relation Instance
A DOMAIN is the set of all possible values for a specific attribute
![Page 35: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/35.jpg)
35 © 2011 IBM Corporation
• Overview
• Entity-relationship diagrams
• The relational model• Entity-Relationship diagrams• Types of relationships• Mapping entities to tables• Relational model concepts• Relational model constraints• Normalization
Agenda
![Page 36: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/36.jpg)
36 © 2011 IBM Corporation
Relational Model Constraints
Business Rules
Book AuthorAuthored By
Referencing
Data Integrity
![Page 37: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/37.jpg)
37 © 2011 IBM Corporation
ERD representation of a Relational Data Model
Primary Key
Foreign Key
Parent TableDependant Table
![Page 38: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/38.jpg)
38 © 2011 IBM Corporation
Constraints
• Entity Integrity Constraint
• Referential Integrity Constraint
• Semantic Integrity Constraint
• Domain Constraint
• Null Constraint
• Check Constraint
![Page 39: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/39.jpg)
39 © 2011 IBM Corporation
Entity Integrity Constraint
Author_ID[PK]
Lastname Firstname Email City Country
A1 Chong Raul [email protected] Toronto CA
A2 Ahuja Rav [email protected] Toronto CA
A3 Hakes Ian [email protected] Toronto CA
A4 Sharma Neeraj [email protected] Chennai IN
A5 Perniu Liviu [email protected] Transilvania RO
AUTHOR
![Page 40: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/40.jpg)
40 © 2011 IBM Corporation
Entity Integrity Constraint
Author_ID[PK]
Lastname Firstname Email City Country
A1 Chong Raul [email protected] Toronto CA
A2 Ahuja Rav [email protected] Toronto CA
A3 Hakes Ian [email protected] Toronto CA
A4 Sharma Neeraj [email protected] Chennai IN
A5 Perniu Liviu [email protected] Transilvania RO
AUTHOR
![Page 41: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/41.jpg)
41 © 2011 IBM Corporation
Entity Integrity Constraint
Author_ID[PK]
Lastname Firstname Email City Country
A1 Chong Raul [email protected] Toronto CA
A2 Ahuja Rav [email protected] Toronto CA
A3 Hakes Ian [email protected] Toronto CA
A4 Sharma Neeraj [email protected] Chennai IN
A5 Perniu Liviu [email protected] Transilvania RO
AUTHOR
NULL
![Page 42: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/42.jpg)
42 © 2011 IBM Corporation
Entity Integrity Constraint
Author_ID[PK]
Lastname Firstname Email City Country
A1 Chong Raul [email protected] Toronto CA
A2 Ahuja Rav [email protected] Toronto CA
A3 Hakes Ian [email protected] Toronto CA
A4 Sharma Neeraj [email protected] Chennai IN
A5 Perniu Liviu [email protected] Transilvania RO
AUTHOR
NULL
NULL
![Page 43: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/43.jpg)
43 © 2011 IBM Corporation
Referential Integrity Constraint
Book AuthorAuthored By
Referencing
![Page 44: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/44.jpg)
44 © 2011 IBM Corporation
Semantic Integrity Constraint
Author_ID[PK]
Lastname Firstname Email City Country
A1 Chong Raul [email protected] Toronto CA
A2 Ahuja Rav [email protected] Toronto CA
A3 Hakes Ian [email protected] Toronto CA
A4 Sharma Neeraj [email protected] Chennai IN
A5 Perniu Liviu [email protected] Transilvania RO
AUTHOR
![Page 45: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/45.jpg)
45 © 2011 IBM Corporation
Semantic Integrity Constraint
Author_ID[PK]
Lastname Firstname Email City Country
A1 Chong Raul [email protected] Toronto CA
A2 Ahuja Rav [email protected] Toronto CA
A3 Hakes Ian [email protected] Toronto CA
A4 Sharma Neeraj [email protected] Chennai IN
A5 Perniu Liviu [email protected] Transilvania RO
12(*)&^23
AUTHOR
![Page 46: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/46.jpg)
46 © 2011 IBM Corporation
Domain Constraint
Author_ID Lastname Firstname Email City Country
A1 Chong Raul [email protected] Toronto CA
A2 Ahuja Rav [email protected] Toronto CA
A3 Hakes Ian [email protected] Toronto CA
A4 Sharma Neeraj [email protected] Chennai IN
A5 Perniu Liviu [email protected] Transilvania RO
AUTHOR
![Page 47: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/47.jpg)
47 © 2011 IBM Corporation
Domain Constraint
Author_ID Lastname Firstname Email City Country
A1 Chong Raul [email protected] Toronto CA
A2 Ahuja Rav [email protected] Toronto CA
A3 Hakes Ian [email protected] Toronto CA
A4 Sharma Neeraj [email protected] Chennai IN
A5 Perniu Liviu [email protected] Transilvania RO
34
34
34
AUTHOR
![Page 48: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/48.jpg)
48 © 2011 IBM Corporation
NULL Constraint
Author_ID Lastname Firstname Email City Country
A1 Chong Raul [email protected] Toronto CA
A2 Ahuja Rav [email protected] Toronto CA
A3 Hakes Ian [email protected] Toronto CA
A4 Sharma Neeraj [email protected] Chennai IN
A5 Perniu Liviu [email protected] Transilvania RO
AUTHOR
![Page 49: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/49.jpg)
49 © 2011 IBM Corporation
NULL Constraint
Author_ID Lastname Firstname Email City Country
A1 Chong Raul [email protected] Toronto CA
A2 Ahuja Rav [email protected] Toronto CA
A3 Hakes Ian [email protected] Toronto CA
A4 Sharma Neeraj [email protected] Chennai IN
A5 Perniu Liviu [email protected] Transilvania RO
NULL
NULL
AUTHOR
![Page 50: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/50.jpg)
50 © 2011 IBM Corporation
Check Constraint
Title Edition Year Price ISBN Pages Aisle Description
Database Fundamentals
1 2010 24.99 978-0-9866283-1-1
300 DB-A02
Teaches you the fundamentals of databases
Getting started with DB2 Express-C
1 2010 24.99 978-0-9866283-5-1
280 DB-A01
Teaches you the essentials of DB2 using DB2 Express-C, the free version of DB2
BOOK
![Page 51: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/51.jpg)
51 © 2011 IBM Corporation
Check Constraint
Title Edition Year Price ISBN Pages Aisle Description
Database Fundamentals
1 2010 24.99 978-0-9866283-1-1
300 DB-A02
Teaches you the fundamentals of databases
Getting started with DB2 Express-C
1 2010 24.99 978-0-9866283-5-1
280 DB-A01
Teaches you the essentials of DB2 using DB2 Express-C, the free version of DB2
2015
BOOK
![Page 52: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/52.jpg)
52 © 2011 IBM Corporation
• Overview
• Entity-relationship diagrams
• The relational model• Entity-Relationship diagrams• Types of relationships• Mapping entities to tables• Relational model concepts• Relational model constraints• Normalization
Agenda
![Page 53: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/53.jpg)
53 © 2011 IBM Corporation
Normalization■ Process in database design to remove redundancies■ Example:
Consider the following table listing all the tasks of an employee:
Problem: If John moves to a new city, all entries related to John must be updated
![Page 54: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/54.jpg)
54 © 2011 IBM Corporation
Normalization (continued)No redundancy, no anomalies, no loss of information
![Page 55: 1.1 - Relational Database Concepts1](https://reader034.fdocuments.net/reader034/viewer/2022052509/55cf99dc550346d0339f8d27/html5/thumbnails/55.jpg)
55 © 2011 IBM Corporation
Thank you!