Professional Documents
Culture Documents
Itd 256 02
Itd 256 02
Database Concepts
Lecture 02
Agenda
Database
DBMS
Database System
Recap HW1
Relations
Keys
Referential Integrity Constraint
Class Exercise
HW2
Quiz
Agenda
Database
DBMS
Database System
Recap HW1
Relations
Keys
Referential Integrity Constraint
Class Exercise
HW2
Quiz
Database System
2 main Database System Component
Database
DBMS
Database
Database
Self-describing collection of related tables
logically stored together to facilitate integration
and sharing
Self-describing Description of structure
contained within database itself
Related tables Interrelated data
Database
Database Contents
Agenda
Database
DBMS
Database System
Recap HW1
Relations
Keys
Referential Integrity Constraint
Class Exercise
HW2
Quiz
DBMS
2nd Database System Component
DBMS
Functions of a DBMS
DBMS
Functions of a DBMS
Enforce rules
Data Types
Limited list or choices
Business driven rules
Referential Integrity Constraints
Rules to control data referenced by related values in
related tables
DBMS
Functions of a DBMS
Concurrency
Ensuring one users work does not interfere
with another users work
DBMS
Functions of a DBMS
Security
Authentication
Authorization
Encrypted Information
Audit Trail
Transaction Log
DBMS
Functions of a DBMS
Backup/Recovery
Ensure no loss of Data in event of errors
(hardware, software, natural, or human)
Backup strategies
Restore from multiple media & sites
DBMS
Functions of a DBMS
DBMS
DBMS
DBMS
MySQL 5.6
Agenda
Database
DBMS
Database System
Recap HW1
Relations
Keys
Referential Integrity Constraint
Class Exercise
HW2
Quiz
Database System
Database System
Agenda
Database
DBMS
Database System
Recap HW1
Relations
Keys
Referential Integrity Constraint
Class Exercise
HW2
Quiz
HW 1
1. Figure above shows a list that is used by a veterinary office. Give examples of three
modification problems that are likely to occur when using this list. (3pts)
2. Break the list in figure above into two tables, each with data for a single theme. Assume
that owners have a unique OwnerEmail and pets have unique PetName column. Indicate the
unique identifiers and linking column. (5pts)
3. Describe how the tables you created in Q2 solves the problems you identified in Q1. (3pts)
4. Why is it a bad idea to assume PetName as a unique identifier? (2pts)
5. What is the difference between data and information? (2pts)
6. How is relational model better than traditional file processing? (2pts)
7. Describe in your own words how relationships between single themed tables are
represented in a relational database. (2pts)
8. Define the term database. (2pts)
9. What is a DBMS? (2pts)
10. Define the term Data Anomaly and give an example. (2pts)
Agenda
Database
DBMS
Database System
Recap HW1
Relations
Keys
Referential Integrity Constraint
Class Exercise
HW2
Quiz
Relations
Relational model developed in 1970s by E.F. Codd
Referred tables as Relations hence the term RDBMS
Relations
Characteristics of a Relation
Relations
Are all relational characteristics satisfied?
Relations
What relational characteristics are violated?
Relations
What relational characteristics are violated?
Relations
What relational characteristics are violated?
Relations
Presenting Relation Structure
RELATION_NAME(Col01, Col02, , , LastColumn)
Table or relation name is all uppercase
Column names have first letter capitalized for each word
No blank spaces in Relation or Table names
Relationships are inherent within data, there are no explicit
linkage between tables
Relations
Presenting Relation Structure
EMPLOYEE table is represented as
Relations
Equivalent Sets of Terms
Agenda
Database
DBMS
Database System
Recap HW1
Relations
Keys
Referential Integrity Constraint
Class Exercise
HW2
Quiz
Keys
Key
One or more columns of a table that is used
to identify a row
A key can be
Unique
Nonunique
Keys
Unique Key
Query produces single row
Unique keys?
Keys
Nonunique Key
Query produces multiple rows
Nonunique keys?
Keys
Composite Keys
Keys
Candidate Keys
Keys
Primary Key
The candidate key that is chosen as the key that DBMS will use to
uniquely identify each row in a relation
Best practice states that PRIMARY keys are short, numeric, and
never change the value
If EmployeeID is chosen as the PRIMARY KEY:
EMPLOYEE (EmployeeID, SSN, FirstName, LastName, Department,
WorkEmail, HomePhone, CellPhone, ManagerID)
Keys
Surrogate Key
Unique values are assigned each time a row is created, like auto-number
Recall that ideal primary keys are short, numeric, & never changes
Keys
Foreign Key
When an attribute in a table A is a Primary key in table B, then that
attribute in table A is called a Foreign key to table B.
Keys
Foreign Key
Recall: Relationships are inherent within the data there
are no explicit linkages between tables.
Foreign Keys form relationship between related tables.
Agenda
Database
DBMS
Database System
Recap HW1
Relations
Keys
Referential Integrity Constraint
Class Exercise
HW2
Quiz
Agenda
Database
DBMS
Database System
Recap HW1
Relations
Keys
Referential Integrity Constraint
Class Exercise
HW2
Quiz
Exercise
A __________ is the organization of data as a conceptual
__________ of how the database is constructed.
When an attribute in a table A is a __________ key in table B, then
that attribute in table A is called a __________ key to table B.
CUSTOMER
PRESCRIPTION
What are Primary keys? Need for Surrogate key?
Parent/Child tables, Foreign keys?
Referential Integrity Constraint statement?
STUDENT
DORM
EMPLOYEE
DEPARTMENT
ATTORNEY_MEETING
CLIENT
Agenda
Database
DBMS
Database System
Recap HW1
Relations
Keys
Referential Integrity Constraint
Class Exercise
HW2
Quiz
HW 2
1. Explain the difference between a primary key and a candidate key. (2pts)
2. What is a surrogate key and why would you use one? (2pt)
3. Explain the term foreign key. (2pt)
4. Define the term referential integrity constraint. (2pts)
5. Define the terms functional dependency and determinant. (2pts)
6. Define the term primary key in terms of functional dependencies. (2pts)
7. Draw Relations Equivalent set of terms for Table, Row, and Column. (2pts)
8. In your own words, describe the purpose of the normalization process. (2pts)
Agenda
Database
DBMS
Database System
Recap HW1
Relations
Keys
Referential Integrity Constraint
Class Exercise
HW2
Quiz
Quiz Exercise
CLIENT schema fields
ClientFirst
ClientLast
ClientID
ClientEmail
AttorneyName
AttorneyEmail
AttorneyLocation
Assume a client is assigned an Attorney but attorney serves many clients
Draw the single themed solution
Quiz Exercise
CLIENT schema fields
ClientFirst
ClientLast
ClientID
ClientEmail
AttorneyName
AttorneyEmail
AttorneyLocation
Assume a client is assigned an Attorney but attorney serves many clients
CLIENT
ATTORNEY
Identify the fields
Quiz Exercise
CLIENT schema fields
ClientFirst
ClientLast
ClientID
ClientEmail
AttorneyName
AttorneyEmail
AttorneyLocation
Assume a client is assigned an Attorney but attorney serves many clients
Quiz Exercise
CLIENT schema fields
ClientFirst
ClientLast
ClientID
ClientEmail
AttorneyName
AttorneyEmail
AttorneyLocation
Assume a client is assigned an Attorney but attorney serves many clients
Quiz Exercise
CLIENT schema fields
ClientFirst
ClientLast
ClientID
ClientEmail
AttorneyName
AttorneyEmail
AttorneyLocation
Assume a client is assigned an Attorney but attorney serves many clients
Quiz Exercise
CLIENT (ClientFirst, ClientLast, ClientID, ClientEmail, AttorneyEmail)