You are on page 1of 49

Introduction to

Applied Database
System
CSB3
Topics

 Definition of Terms
 Creation of File and Entering Records
 Datasheet Records
 Sorting and Filtering
 Normalization Process
 Table Relationships
What is Database?

 A collection of data
 That is organized
 So that it can easily be accessed, managed and updated
What is Database Management
Systems(DBMS)?

 A collection of programs
 That enables you to :
− input
− organize
− select data
in a database
Definition of Terms

 Database schema – structure of database


system supported by DBMS
 Schema – how the database is organized
 Table
 where data is placed
 a two dimensional representation of
data consisting of one or more columns,
and zero or more rows
Definition of Terms

Name course Contact no.

Juan dela BSN 1234567


Cruz
Maria Reyes BSHM 1345678

 Field - a single piece of information


 Record - one complete set of fields
 File - a collection of records
Exercise:

Create a table on the following:


1. Address book
2. College and courses offered in USJR
Entities and Attributes

Entity – a person, place, thing or concept


about which data can be
collected

Attribute – describes the facts, details or


characteristics of an entity
- represents an entity
Exercise:

Write the attributes of the following entities.


1. Employee
2. Customer
3. Patient
4. Sales
5. Registration
Table Naming Convention

 Table names must be unique


 Within a table, column names must be
unique
 Within a table, rows must be unique
 Column and row order is arbitrary
 Each cell in the table contains exactly one
value
Example

Student Information
studentID Last name First name Gender
2010-1000 Cruz Maria F
2009-1234 Abad Maria M
2010-10001 Perez Juan M
2010-10003 Reyes Pedro M
Example of Tables

 Course
 Student information

Student Information
studentID Last name First name Course
2010-1000 Cruz Maria BSN
2009-1234 Abad Maria BSECE
2010-10001 Perez Juan BSN
2010-10003 Reyes Pedro BSIE
What are NULL Values?

 are missing or unknown values


 are not the same as blanks
 are not the same as zeroes

All fields must have a value.


(True or False)
courseTable
courseCode courseDescription
BSA Bachelor of Science in Accountancy
BSIT Bachelor of Science in Information
Technology
BSEE Bachelor of Science in Electrical
Engineering
BSN Bachelor of Science in Nursing
studentNo Name contactNo courseCode
120 Maria Reyes 123434 BSA
121 Juan Tan 232323 BSIT
231 May Gomez 124554 BSEE
122 Paul Cruz BSEE
105 Juan Gomez 124554 BSA
Duplicate Values

 When a value in one column matches


exactly another value in the same column
 ND – No Duplicate

Example
Changeable Values

 A value in the table that may vary over


time
 NC – No Changes

Example
Primary Keys

 Column or group of columns whose values


uniquely identify each row of that table
 Every table must have a primary key
 Every table must have only one primary key
 PK – Primary Key
 Can be assigned by the system (SA) or user
assigned (UA)
Primary Key Constraints

 Must never be null


 Must never be duplicated
 Must never be changed
 Does not influence column order
 Does not influence row order
 Does not influence row access
Primary key

 Can be assigned by the system


 Can be user-assigned
Examples:
1. Student number
2. Employee id
3. Course
4. College
5. Patient no / patient id
6. Doctor id
Foreign Keys

 A column or group of columns that is a


primary key in another table
 FK may be null
 FK can contain duplicate values
 FK must refer to existing PK values
(Referential Integrity)

Example
Derivative Data

 Data that is calculated from data defined elsewhere in a


model
subjectTable

courseCode courseDescription studentCount


BSA Bachelor of Science in Accountancy 10
BSIT Bachelor of Science in Information 8
Technology
BSEE Bachelor of Science in Electrical 7
Engineering
NORMALIZATION
PROCESS
What is normalization?

 Process of organizing data to minimize


redundancy
 Process of dividing the tables and
setting the relationship between tables
Entity

 is a distinct object (a person, place or thing,


concept or event) in the organization that is to
be represented in the database
Purpose of Normalization

 Insertion Anomalies
 Deletion Anomalies
 Modification Anomalies
Student_Course
studNo Name year courseCode courseDesc
100 Lorna 1 BSA Accountancy
101 Ricky 2 BSMA Management Accounting
120 Juvy 4 BSIT Information Technology
320 Joy 4 BSA Accountancy
121 Roy 3 BSCE Civil Engineering
Process of normalization: 1NF
(First Normal Form)

• Remove repeating groups of attributes and split into 2 or


more tables
• Underline key attributes that uniquely identify the rows
in each new table
Student_Course
studNo Name year courseCode courseDesc College
100 Lorna 1 BSA Accountancy COM
101 Ricky 2 BSMA Management COM
Accounting
120 Juvy 4 BSIT Information CICCT
Technology
320 Joy 4 BSA Accountancy COM
121 Roy 3 BSA Accountancy COM
1nf

 Every column in the table must be unique


 Separate tables must be created for each set of related
data
 Each table must be identified with a unique column or
concatenated columns called the primary key
 No rows may be duplicated
 no columns may be duplicated
 no row/column intersections contain a null value
 no row/column intersections contain multivalued fields
EXAMPLE:

How do you fix the table to 1NF?


Product ID Color Price
1 Red, green 20.25
2 Yellow 50.00
3 Red, blue 45.00
4 green, pink 68.90
5 Blue 89.90
6 orange 47.89
Product ID Price Product ID Color
1 20.25 1 Red
2 50.00 1 green
3 45.00 2 Yellow
4 68.90 3 red
5 89.90 3 Red
6 47.89 4 green
4 pink
5 Blue
6 Orange
Example:
ID Name Age Address Order
100 Mark 20 Cebu Samsung
Monitor
101 Gene 30 Talisay Canon
Printer
100 Mark 20 Cebu Flash
Drive 32G
101 Gene 30 Talisay PS2
Keyboar
d
Process of normalization: 2NF
(second Normal Form)

Isolate any attributes not dependent on the table’s


concatenated (composite) primary key

How to know if the table is in 2NF?


• it is in 1NF
• All non-key attributes are fully functional
dependent on the primary key
Process of normalization: 2NF
(second Normal Form)

Isolate any attributes not dependent on the table’s


concatenated (composite) primary key

Student_Course
studNo Name year courseCod courseDesc College
e
100 Lorna 1 BSA Accountancy COM
101 Ricky 2 BSMA Management COM
Accounting
120 Juvy 4 BSIT Information CICCT
Technology
320 Joy 4 BSA Accountancy COM
121 Roy 3 BSCE Civil Engineering ENG
Process of normalization: 3NF
(Third Normal Form)

• Remove attributes dependent on data item(s)


other than the primary key

How to know if the table is in 3NF?


• It is in 2NF
• All non-primary fields are dependent on the
primary key
Student_Course
studNo Name year courseCode courseDesc College
100 Lorna 1 BSA Accountancy COM
101 Ricky 2 BSMA Management COM
Accounting
120 Juvy 4 BSIT Information CICCT
Technology
320 Joy 4 BSME Mechanical ENGG
Engineering
105 Lisa 2 BSME Mechanical ENGG
Engineering
courseTable
courseCode courseDescription
BSA Accountancy
BSIT Information Technology
BSEE Electrical Engineering
BSMA Management Accounting

Student_Course
studNo Name year courseCod courseDesc
e
100 Lorna 1 BSA Accountancy
101 Ricky 2 BSMA Management
Accounting
120 Juvy 4 BSIT Information
Technology
320 Joy 4 BSA Accountancy
Example 1:

Given the following fields in an excel table with the


following column headings:
employee number, first name, last name, birth
date,depCode, depName, contact number,
email address, gender, and status(full time or part
time), branchCode, depContactNo,
branchName, branchAdd
Employee
employeeID, first name, lastname, contact number, birthdate,email
address, gender, status, depCode

Department
depCode, depName, depContactNo, branchCode

Branch
branchCode, branchname, branchAdd
Example 2:

Given the following fields in a table. There are five


doctors in a clinic. How can the data be
normalized?

Petname, owner, address, contact no,


doctorName, doctorAdd, doctorContactNo
Example 3:

The table below displays the names of the children


of the employees of a company. Is there a better
way to construct the table such that data can be
retrieved without any anomalies?
empNo empName depID depNam Child1 Child2 Child3
e
100 Juan Reyes D1 Sales John Reyes Johna Reyes
101 Maria Cruz D2 Finance Marie Cruz
120 Jack Gusman D1 Sales
128 John Go D3 Marketin Johnny Go May Go Marie Go
g
 Example 4:

studentNo subjectCode (ex: 1012)


Bdate courseDesc (ex: Algebra)
Fname Units
Lname Time
maternalName Days
Gender room
Course
Year
courseCode (ex:
Math1)
Modeling
Relations
Relations

 A mode of being, an association, an action or an event


that connects two or more entities together
Types of Relations

 One-to-One Relation
 One-to-Many Relation
 Many-to-Many Relation
Steps in Modeling Relations

1. Discover a relation
2. Define the scope of the relation
 Is it important to the user?
3. Determine the type of relation
 Can entity A be related to more than one entity B?
 Can entity B be related to more than one entity A?
 Answers:

 2No answers = 1 to 1
 1Yes/1No = 1 to many
 2Yes answers = many2many
Identify the type of relationship exhibited by
the following:
1. Student and course
2. Country and capital
3. Employee and employeeID
4. Doctor and patient
5. Pet and owner
6. Biological mother and children
7. Books and authors

You might also like