Sunteți pe pagina 1din 39

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 Cruz BSN 1234567

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
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 323333 BSEE
105 Juan Gomez 124554 BSA
Duplicate Values

 When a value in one column matches


exactly the 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
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
Eng.
courseTable
courseCode courseDescription
BSA Accountancy
BSIT Information Technology
BSEE Electrical Engineering
BSMA Management Accounting

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
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
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 courseCode courseDesc College
100 Lorna 1 BSA Accountancy COM
101 Ricky 2 BSMA Management COM
Accounting
120 Juvy 4 BSIT Information Technology CICCT
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

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 Technology CICCT
320 Joy 4 BSA Accountancy COM
121 Roy 3 BSCE Civil Engineering ENG
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
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 departm depName Child1 Child2
entID
100 Juan Reyes D1 Sales John Reyes Johna Reyes
101 Maria Cruz D2 Finance Marie Cruz
102 Sarah Palo D1 HR
 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. Course and college
3. Course and school
4. Doctor and patient
5. Instructor and school
6. Student and school

S-ar putea să vă placă și