![Page 1: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/1.jpg)
Presenter:
Jorge Barba
![Page 2: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/2.jpg)
Describe the Relational Data Model componentsModel Entities, Relationships and Attributes
Translate a Data Model Diagram into Schema Data types Learn the mapping of
Attributes to Data TypesEntities to Tables
Relationships to Foreign Keys
Learn SQL SELECT statementUnderstand the Projection, Filtering, Join, and Order
![Page 3: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/3.jpg)
Why Data Modeling?
Target: The System.
Application: To automate data management, to generate reports, to record activity.
Examples: Facebook, Amazon, Oracle E-Business Suite, Nowait.
Databases hold the data, the application is used to enter, modify, remove the data, and generate reports. Together the Database and the Application are “The System”.
![Page 4: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/4.jpg)
Scientific Model
Conceptual Model, Entity Relationship Model, Data Modeling
Conceptual Model vs Physical Model
Business Rules/Business Functionality vs Programs/Applications
Tables and Programs are the target but we start with The Model
![Page 5: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/5.jpg)
It describes the information needs of the business (Requirements)
It facilitates discussion
It helps to prevent mistakes
Common language between Developers, Designers, DBAs
A model forms a basis for the design of the physical database
Regardless of the final Database destination the Model works for any physical implementation
![Page 6: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/6.jpg)
Out of everything out there in the World
What do I care about to have in … “The System”?
Example: Camera Store
![Page 7: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/7.jpg)
We want to sell cameras and lenses
Mainly Nikon, Canon, Sony, Fujifilm and some other brands
No bundles, lens sold separately
We will have different technologies from DSLR to Mirrorless to Film
We are interested in comparing features like ISO Sensitivity Range, Top Continuous Speed (FPS), Movie Resolution, Sensor Size, Effective Pixels (Megapixels)
The orders from Customers are archived
We don’t care about accounting, stock control, payroll
![Page 8: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/8.jpg)
Find out the entities for the Camera Store
![Page 9: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/9.jpg)
Out there in the world what interests me for The System
The business wants to keep information about it
An ENTITY is a class or type of things
Entities have instances
An ENTITY is usually a noun
![Page 10: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/10.jpg)
The attributes DESCRIBE the entity
An attribute is a property of the entity
We are interested only in attributes relevant to “The System”
Attributes have values
An attribute value can be a number, a character string, a date, an image.
![Page 11: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/11.jpg)
Distinction between an ENTITY, an attribute, and an instance of an entity.
![Page 12: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/12.jpg)
Find out the attributes for Camera
![Page 13: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/13.jpg)
![Page 14: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/14.jpg)
How the entities are mutually related
Always exist between two entities
Have two perspectives
Are named at both ends
![Page 15: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/15.jpg)
RELATIONSHIP EXAMPLESEMPLOYEES have JOBS
JOBS are held by EMPLOYEES
PRODUCTS are classified by a PRODUCT TYPE
PRODUCT TYPE is a classification for a PRODUCT
PEOPLE make TICKET RESERVATIONS
TICKET RESERVATIONS are made by PEOPLE
![Page 16: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/16.jpg)
All EMPLOYEES have a JOBNo EMPLOYEE has more than one JOB
Not all JOBS are held by an EMPLOYEE
Some JOBS are held by more than one EMPLOYEE
ShintaroJill
AdamAhmed
Maria
ManagerCook
WaitressDish washer
Financial controllerPorter
WaiterPiano player
![Page 17: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/17.jpg)
Before we see details on Relationships we open a parenthesis to see how to represent the model
![Page 18: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/18.jpg)
* Mandatory attribute
o Optional attribute
EMPLOYEE* Family Name* Addresso Birth Dateo Shoe Sizeo Email
JOB* Title* Description
Attributes in Diagrams
![Page 19: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/19.jpg)
An employee has exactly one job
EMPLOYEEJOBhas
held by
Mandatory: Optional:
FK
![Page 20: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/20.jpg)
All EMPLOYEES have a JOBNo EMPLOYEE has more than one JOB
Not all JOBS are held by an EMPLOYEE
Some JOBS are held by more than one EMPLOYEE
ShintaroJill
AdamAhmed
Maria
ManagerCook
WaitressDish washer
Financial controllerPorter
WaiterPiano player
![Page 21: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/21.jpg)
How do you relate to others?
Do you have good relations?
You Are The Average Of The Five People You Spend The Most Time With
![Page 22: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/22.jpg)
1:m
(a)
(b)
(c)
(d)
Optional: Mandatory:
![Page 23: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/23.jpg)
m:m
(e)
(f)
(g)
Optional: Mandatory:
![Page 24: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/24.jpg)
1:1
(h)
(i)
(j)
Optional: Mandatory:
![Page 25: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/25.jpg)
Group the various types of information into entities and attributes.
Name the relationships and draw a diagram.
![Page 26: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/26.jpg)
Read a relationship.
![Page 27: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/27.jpg)
Use your knowledge of people and towns.
![Page 28: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/28.jpg)
Use your knowledge of shopping.
![Page 29: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/29.jpg)
m:m
![Page 30: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/30.jpg)
Quantity is an attribute of . . .
![Page 31: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/31.jpg)
Quantity is an attribute of . . .
![Page 32: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/32.jpg)
New Entity ORDER
FK1 FK2
![Page 33: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/33.jpg)
Multiple PRODUCTS for an ORDER
![Page 34: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/34.jpg)
Another New Entity : ORDER ITEM
![Page 35: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/35.jpg)
Another New Entity : ORDER ITEM becomes the ORDER_ITEMS table
FK1 FK2
FK
![Page 36: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/36.jpg)
The key to a good model and a good life is GOOD RELATIONS
![Page 37: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/37.jpg)
Read the Relationship
![Page 38: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/38.jpg)
Relationships express how entities are connected.
Initially relationships often seem to be of type m:m.
Finally relationships are most often of type m:1.
Relationships can be resolved into: – Two new relationships. – One intersection entity.
Third Normal form is generally accepted standard.
![Page 39: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/39.jpg)
![Page 40: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/40.jpg)
![Page 41: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/41.jpg)
DDL
![Page 42: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/42.jpg)
![Page 43: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/43.jpg)
DML
SELECT
INSERT
UPDATE
DELETE
MERGE
DDL
CREATE
ALTER
DROP
RENAME
TRUNCATE
DCL
GRANT
REVOKE
Transaction Control
COMMIT
ROLLBACK
SAVEPOINT
![Page 44: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/44.jpg)
Using the Order Entry (OE) sample schema
Tables: CUSTOMERS
![Page 45: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/45.jpg)
Using the Order Entry (OE) sample schema
Tables: ORDERS
![Page 46: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/46.jpg)
Using the WHERE clause in the SELECT statement to filter the rows with a condition
![Page 47: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/47.jpg)
Using the WHERE clause in the SELECT statement to filter the rows with two conditions
![Page 48: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/48.jpg)
Using the WHERE clause in the SELECT statement to JOIN two tables and to filterthe rows with two conditions
![Page 49: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/49.jpg)
Using the ORDER BY clause in the SELECT statement to order by order date in descending order (most recent orders first)
![Page 50: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/50.jpg)
Not really
It depends
It is iterative prior to physical phase
Once the structures are built the process does not iterate
Modifications are needed but more like change management not as repetitive iterations
Everyone has its own methodology
![Page 51: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/51.jpg)
![Page 52: Presenter: Jorge Barba · 2019-03-22 · Piano player. Before we see details on Relationships we open a parenthesis to see how to represent the model * Mandatory attribute o Optional](https://reader034.vdocuments.net/reader034/viewer/2022042100/5e7d1a7b8bfdd66f06258abf/html5/thumbnails/52.jpg)
Data Modeling and Relational Database Design Volume 1 Student Guide – Oracle Corp.
Oracle Database: SQL Fundamentals I Student Guide – Oracle Corp.
Data Modeling and Database Design - Minder Chen, Ph.D.
Database Analysis and ER Modeling: db.grussell.org
DB Design Tutorial: California State University Long Beach, Department of Computer Engineering and Computer Science: web.csulb.edu/colleges/coe/cecs/dbdesign
Web Database Applications with PHP and MySQL: Entity Relationship Modeling docstore.mik.ua/orelly/webprog/webdb/appc_02.htm
Guru 99: https://www.guru99.com/database-normalization.html