5. 5
CHARACTERISTICS OF A RELATIONAL
TABLE
Characteristics of a Relational Table (TutorialsPoint, 2020)
6. 6
KEYS
Consist of one or more attributes that
determine other attributes
Used to
Ensure that each row in a table is uniquely
identifiable
Establish relationships among tables and ensure data
integrity
Primary key (PK)—Attribute or combination of
attributes that uniquely identifies a row
Source: Microsoft Images
11. 11
WAYS TO HANDLE NULLS
NOT NULL constraint—Placed on a column to ensure that every
row in the table has a value for that column
UNIQUE constraint—Restriction placed on a column to ensure that
no duplicate values exist for that column
Is a field NOT NULL or UNIQUE in your database model? Be sure
to indicate this in your Data Dictionary.
13. 13
DATA MODELING OBJECTIVES
Understand concepts of data modeling and its purpose
Learn how relationships between entities are defined and refined, and how
they are incorporated into the database design process
Learn how ERD components affect database design and implementation
Learn how to interpret the modeling symbols
14. 14
IMPORTANCE OF DATA MODEL
Blueprint—official documentation
blueprint of house
Employees w/o DB knowledge can understand
a data model diagram vs. a list of tables
an effective communication tool
improves interaction among managers,
designers, and end users
Independence from a particular DBMS
network DB, object-oriented DB, etc.
15. 15
DATA MODEL
Model—an abstraction of a real-world
object or event
useful in understanding complexities of the
real-world environment
Data model
a diagram that displays a set of tables and
the relationships between them
a foundation
next slides: Draw.io Entity Relationship
Diagram (ERD) examples
West and Fowler (1999)
16. 16
ENTITY RELATIONSHIP DIAGRAM
(ERD) PROCEDURE
Relatively simple representations of complex real-world data
structures
Data modeling is an iterative process.
A "complete" and "100% error free" data model is impossible!
An "optimized" data model is possible …
19. 19
WHAT IS AN ERD?
ERD is a data modeling technique used in
software engineering to produce a conceptual
data model of an information system.
ERDs illustrate the logical structure of
databases.
ERDs represent 'business' or 'use' cases
21. 21
DATA MODEL—ERD
The data modeling
revolves around
discovering and analyzing
organizational and user's
data requirements (use
cases).
Requirements based on
policies, meetings,
procedures, system
specifications, etc.
• Identify what data is
important
• Identify what data should
be maintained
22. 22
DATA
MODEL—
ERD
The major activity of this phase is
identifying entities, attributes, and
their relationships to construct model
using the Entity Relationship Diagram.
"Logical" (or design) names include:
Entity/Attribute/Relationship
"Physical" implementation names
include: Table, Column, Line
Entity à table
Attribute à column
Relationship à line
24. 24
ENTITY
An Entity is a collection of data, using
a rectangle with attributes listed inside
the entity ‘box.'
For example, an entity STUDENT could
include the attributes StudentID, Name,
Registered, Region, etc.
A second entity following this example
would be COURSE, which would
include the attributes Title, Credit,
Quota.
27. 27
ENTITY
An entity is a collection of data, using a
rectangle with attributes listed inside the
entity "box." For example, STUDENT
could include the attributes student_id,
student_name, student_address, etc.
A second entity following this example
would be COURSE, which would include
the attributes course_name,
course_number, etc.
28. 28
CROW'S FOOT NOTATION
FOR ENTITY
Entity:
Represented by a rectangle, with its name on the top. The name is singular (entity)
rather than plural (entities). Entity name can be upper case (ENTITY) or lower case
(entity).
29. 29
HOW TO FIND ENTITIES
Entity—a person, place, object, or event about which you can store
information (e.g. supplier, machine tool, employee, utility pole, airline
seat, etc.).
Tangible: CUSTOMER, PRODUCT
Intangible: ORDER, ACCOUNTS RECEIVABLE
Look for singular nouns (beginner)
Some ″standards″ place entity names in UPPER CASE (not required)
A proper noun is not a good candidate …
30. 30
ATTRIBUTES
Within the Entity (for example, within the student entity) are
attributes describing the student.
Crow's foot Chen style
31. 31
ATTRIBUTES
Describe details about an
entity
Entity: Employee
Attributes:
Employee-Name
Address (composite)
Phone Extension
Date-of-Hire
Job-Skill-Code
Salary
32. 32
ATTRIBUTES
• The individual bits of data that make up an
entity.
• Attributes are listed within the entity.
• If an attribute is used to identify the entity, it
is the primary key and is underlined or
preceded with an *.
• If it refers to the identifying attribute of
another entity, it is a foreign key and is
commonly italicized (not in this model).
• If you aren't actually storing an attribute, but
calculating it from other attributes, it's a
derived attribute, and has a dashed outline.
33. 33
HOW TO FIND ATTRIBUTES
Attributes are
Data objects that either identify or
describe entities (property of an
entity).
Descriptors whose values are
associated with individual entities of a
specific entity type.
To identify attributes, find and extract the
names that appear to be descriptive noun
phrases.
34. 34
TERMINOLOGY: ENTITY INSTANCE
Entity instance—a single occurrence within the entity.
This example contains six entity instances.
Student
ID
Last
Name
First
Name
2144 Arnold Betty
3122 Taylor John
3843 Simmons Lisa
9844 Macy Bill
2837 Leath Heather
2293 Wrench Tim
Entity:
STUDENT
instanc
e
35. 35
TYPES OF ENTITIES
A weak entity is shown as a double rectangle in a
data model, because it doesn't have its own unique
key—it only exists in relation to the entity it belongs
to.
An associative entity (easier to see in the second type
of diagram), is shown with a dashed outline and
connector. This type of entity is needed wherever you
have many-to-many relationships. To create an
associative entity in the first style of diagram, add an
entity shape and a relationship shape, and group the
two shapes together.
37. 37
SIMPLE/COMPOSITE ATTRIBUTE
A simple attribute cannot be subdivided.
Examples: age, gender, marital status
A composite attribute can be further subdivided to yield
additional attributes.
Examples:
ADDRESS à Street, City, State, Zip
PHONE NUMBER à Area code, Exchange
38. 38
IDENTIFIER (PRIMARY KEY AND
COMPOSITE IDENTIFIER)
Attributes that uniquely identify
entity instances become a
Primary Key (PK) in an RDBMS
39. 39
DERIVED ATTRIBUTE
Not physically stored within the database
Derived by using an algorithm
Example 1: Late Charge of 2%
MS Access: InvoiceAmt * 0.02
Example 2: Age can be derived from the date of birth and the current date.
MS Access: int(Date() – Emp_Dob)/365)
40. 40
SINGLE-VALUED ATTRIBUTE
Can have only a single (atomic) value.
Examples:
A person can have only one social security number.
A manufactured part can have only one serial number.
A single-valued attribute is not necessarily a simple attribute.
Part No: CA-08-02-189935
Location: CA, Factory#:08, shift#: 02, part#: 189935
41. 41
MULTI-VALUED ATTRIBUTES
Can have many values.
Examples:
A person may have several college degrees.
A household may have several phones with different
numbers.
A car can be one or more colors.
42. 42
RELATIONSHIPS Relationships (relationship lines) show
how entities are related to each other.
Relationships occur between each pair of
entities.
Relationship lines are bidirectional
(operate in both directions).
Relationship connectors use Crow's foot
notation to show how many of each
entity are related to another entity.
Example (relationship between student
and enrollment)
oOne student has one or more enrollments
oOne enrollment has only one student
43. 43
HOW TO FIND RELATIONSHIPS
o Relationships are associations between
two or more entities.
o Typically, a relationship is indicated by a
verb connecting two or more entities.
o Relationships should be classified in terms
of cardinality.
§Cardinality: one-to-one, one-to-
many, etc.
44. 44
MORE ABOUT RELATIONSHIP
Business rule of a relationship should be bidirectional.
A student must be enrolled in many curriculums (student to
curriculum).
Each curriculum might be studied by many students (curriculum
to student).
45. 45
CROW'S FOOT—1:1, OPTIONAL RELATIONSHIP
(OR) ON ONE SIDE
A person might or might not be a programmer, but a programmer
must be a person.
SUB TYPE
ProgrammerPerson 2
Crow's Foot – 1: 1 (McFarland, 2020)
46. 46
CROW'S FOOT—1:M RELATIONSHIP
Each department hires many employees, and each
employee is hired by one department.
EMPLOYEEDEPARTMT
HIRES
IS_HIRED_BY
Crow's Foot – 1:M (McFarland, 2020)
47. 47
CROW'S FOOT—1:M WITH OR ON
MANY SIDE
A person might be or might not be a member, but could be found multiple
times (if the member entity represents membership in multiple clubs, for
instance). A member must have only a single person.
CHILD
MEMBERPERSON
48. 48
CROW'S FOOT: 1:M WITH OR ON
BOTH SIDE
A person might have no phone, one phone, or lots of
phones, and that phone might be unowned or can only be
owned by a person.
POSSESSION
PHONEPERSON 4
49. 49
CROW'S FOOT—M:N RELATIONSHIP
Each student takes many classes, and a class must be
taken by many students.
Note: Many-to-many relationships cannot be allowed in the data
model because they cannot be represented by the relational
model.
STUDENTCLASS
TAKES
IS_TAKEN_BY
51. 51
REVIEW: KEY TERMS IN THE
RELATIONAL MODEL
What is a
Database?
How is a
Database
different from
a Database
Management
System?
What is a
Schema?
What is
Metadata?
52. 52
TERMINOLOGY OF THE RDBMS
Logical Name Physical
Implementation Name
Tuple Row (or record)
Attribute Field (or column)
Entity Table
55. 55
REVIEW: PRIMARY KEY AND FOREIGN KEY
Primary key (PK)—A unique identifier for
a record. Each PK must be unique.
Foreign key (FK)—A field within a table
that is a PK in another table.
56. 56
DATABASE SCHEMA OR ENTITY RELATIONSHIP DIAGRAM (ERD)
An Entity Relationship Diagram (ERD)
serves as a 'blueprint' for the database.
An ERD is also known as a Database
Schema.
57. 57
DATABASE SCHEMA OR ENTITY RELATIONSHIP DIAGRAM (ERD)
What is the Primary Key for lab_orders,
patient_info, primary_care_doctors, and
hospitals?
What are the FKs in each Table?
What type of relationship notation is shown
on the ERD? (tough question)
62. 62
INTERSECTION TABLE AND COMPOSITE KEY (ERD)
A composite key is two or more
fields used to define a primary key
in a table.
63. 63
INTERSECTION TABLE AND COMPOSITE KEY
(TABLE)
A composite key is two or more fields
used to define a primary key in a
table.
64. 64
RDBMS
DML: Data Manipulation Language
DDL: Data Definition Language
Metadata: Data about data
Data Schema: Design of the data
(supported by an ERD)
DBMS vs. Database
65. 65
REFERENCES
Draw.io. (2020). Diagrams.net—free flowchart maker and diagrams online. Retrieved November 23, 2020, from
https://app.diagrams.net/
SQLite Browser. (2020, November 09). DB Browser for SQLite. Retrieved November 23, 2020, from
https://sqlitebrowser.org/
SQLite. (2020). SQLite Main Website. Retrieved November 23, 2020, from https://sqlite.org/index.html
McFarland, R. (2020). Published Articles: Ron McFarland. Retrieved December 03, 2020,
from https://medium.com/@highervista
Tutorialspoint. (2020). SQLite Tutorial. Retrieved November 23, 2020, from
https://www.tutorialspoint.com/sqlite/index.htm
Watt, A. and Eng, W. (2020). Database Design, 2nd edition. Licensed under Creative Commons Attribution 4.0.
Matthew West and Julian Fowler (1999). Developing High Quality Data Models. The European Process Industries
STEP Technical Liaison Executive (EPISTLE).
67. 67
ABOUT THIS COURSE
This course is distributed free. I use several
sources. But importantly, I use the book noted
on the next slide.
If you are using these PowerPoints, please
attribute Highervista, LLC and me (Ron
McFarland). IN ADDITION, please attribute
the author noted on the next slide, as the
author’s textbook provides essential
information for this course.
Source: Microsoft Images
68. 68
INTRODUCTION
This course is offered to you free. HOWEVER, please
purchase the following book, as it is a primary resource for
this course. I do not make any $ from this course or this
book. So, since a handful of good content is derived from the
following text, please support this author!
Title: SQL Quickstart Guide
Author: Walter Shields
Available: Amazon, B&N, and through ClydeBank media
website at:
https://www.clydebankmedia.com/books/programming-
tech/sql-quickstart-guide