You are on page 1of 16

Basic Concepts of Database

1
Database definition
• In general, a database is anything that stores
data
– Example, a phone book which store name &
phone number
• In computer, a database refers to
– collection of organized datato be accessed,
retrieved and used

2
Function of a database in general
• Allow anyoneto:
– store (add)
– delete (remove)
– organize
– use
– present data

3
Example: data in Accessdatabase

4
What is a DBMS?
• Database Management System is asoftware
that store and managedatabase
• It allows to:
• create databases
• insert, update and delete data
• sort and query data
• create forms and reports

5
Examples of DBMS
•Microsoft Access, MySQL, PostgreSQL, SQLServer,
Oracle, dBASE, Clipper andFoxPro
• Examples of DBMS applications:
 Automated teller machine
 Computerized Library System
 Flight Reservation System
 Staff Information System
 Students System

6
Relational Model
• Data is stored in two-dimensional tables (rows and
columns)
• Widely used
• Example, Microsoft Access and MySQL

11
Data Hierarchy
Definition- systematic organization of data, often in a hierarchical
form

Database File Database File: Physical file stored in a storage media.


Example: StudentDB.accdb

Table Table: Contain information on a specific subject / topic.


Example: Student, Courses

Record: Contain information on single data item in a


Record
table. Example: information about a student. Also known
as row in a table.

Field Field: Contain a specific piece of information within a


record. Example: Student Name, Student IC. Also known
as column in a table. 12
Example of an Accesstable

records

fields
13
Relational database
• stores data in tables
• tables are organized into columns, andeach
column stores one type of data
• data for a single “instance” of a table is stored asa
row

14
What is RDBMS?
• RDBMS is a DBMS which manages a relational
database
– Example, Microsoft Access and MySQL
• Data is structured in tables, records and fields
• Each table consists of rows (records)
• Each table row consists of one ormore fields
(columns)
• RDBMS store the data into collection of tables,
which might be related by commonfields
15
Primary Key
• Field, or fields, which by itself, ortogether
uniquely identify each row in atable
• Used to match up records in differenttables
• Usually indexed
• Help to define the relationships betweentables

20
Primary Key
• Requirement: must be unique and cannot be
empty or null
• Functions:
• Used to associate data from multiple tables
• Prevent duplicate record
• Control the order of records
• Faster to locate records
• Possible to have 2 or more fields as primary keyin
a table –this is called composite key
21
Foreign Key
• Same data field and type which is linked to a
primary key in a corresponding table
• Example:
– In SalesTransaction table below, CustomerID would bethe
Foreign Key field
– The Foreign Key is used to look up the CustomerID in the
Customer table where the CustomerID is the primarykey

Customer table SalesTransactiontable


CustomerID (PRIMARY KEY) SalesID
CustomerName SalesDate
CustomerID (FOREIGN KEY) 22
Relationships
• Relationships establishes the association between
common fields in two tables
• Common field links two tables to each other, thus
ensuring connection between the data in the
tables within the samedatabase
• REMEMBER: Access uses related tables - one table
can find and use data in another table

23
PROBLEM-SOLVING
assignment (1/2 yellow paper)
• 1. Develop a simple data model for the music you
have on your MP3 player or in your CD collection,
where each row is a song.
• For each row, what attributes/fields should you
capture?
What will be the unique key for the records in your
database? Describe how you might use the
database

25

You might also like