Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
BAB 7 Pangkalan data new
1. Bab 7
STID 1103 - Aplikasi Komputer
Dalam Pengurusan
Pangkalan Data
Oleh :
Nama : MOHD TARMIZI BIN MUSA
2. Objektif pembelajaran
Setelah selesai bab ini pelajar boleh:-
• Memperkenalkan konsep asas pangkalan data
• Menerangkan model sistem pangkalan data
• Menerangkan evolusi pangkalan data
• Menerangkan operasi asas dalam sistem membina
pangkalan data
• Menerangkan penggunaan jadual, hubungan,
pertanyaan, borang dan laporan.
2
3. Pengenalan
• Dalam IT, data adalah aset yang paling penting untuk memiliki
kerana tanpanya, organisasi akan berhenti berfungsi.
• Data yang memastikan setiap sistem dan proses dalam organisasi
berfungsi pada tahap yang optimum.
• Oleh itu, sumber data perlu disusun dan distrukturkan dengan cara
yang logik supaya boleh dicapai dengan mudah, diproses dengan
cekap, didapatkan semula dengan cepat, dan diuruskan dengan
berkesan.
• Data-data ini boleh diuruskan dengan menggunakan Sistem
pengurusan data.
3
4. Pengenalan (samb…)
• Pengurusan data terdiri daripada semua disiplin
berkaitan dengan pengurusan data sebagai sumber yang
berharga.
• Koleksi atau himpunan data yg disusun ini dipanggil
pangkalan data.
• Pangkalan data digital diuruskan menggunakan Sistem
Pengurusan Pangkalan Data (DBMS), yang menyimpan
kandungan pangkalan data, membolehkan penciptaan
data dan penyelenggaraan, mencari dan lain2 capaian.
4
5. Data vs Information
5
Data
Fakta mentah mengenai suatu
benda, perkara, orang, entiti,
fenomena, himpunan nombor2,
aksara, imej, dan seumpamanya
yang belum diproses.
Maklumat
Data yang telah diproses, disusun
dan mempunyai maksud
tertentu.
RM200
RM250
RM300
1000
2000
1500
Brand A
Brand B
Brand C
DATA
Product
Brand A
Brand B
Brand C
Price
RM200
RM250
RM300
No of Sales
1000
2000
1500
Total sales
RM200,000
RM500,000
RM450,000
Total profit
RM50,000
RM-15,000
RM200,000
INFORMATION
KNOWLEDGE
• Produk B merugikan walaupun hasil
jualan tinggi.
• Naikkan harga produk B.
• Harga kos produk A ialah RM150
6. Sistem Fail Tradisional /
Sistem Pemprosesan Fail
• Sistem berasaskan fail, di mana pengguna mengendalikan fail-fail
dan data secara manual seperti menambah, mengemaskini,
membuang dalam sistem fail contohnya spt resit belian, penyata
akaun, bil2 dsbnya.
• Apabila kita perlu melihat sesuatu, kita pergi ke sistem fail dan
mencari dari kemasukan pertama sehingga kita dapat apa yang
diperlukan.
• Data disusun, disimpan, dan diproses dalam fail yang berasingan.
• Setiap jabatan dalam organisasi memiliki set fail mereka tersendiri.
• Rekod dalam satu fail mungkin tidak berkaitan dengan rekod dalam
mana-mana fail lain.
6
7. HEA Sistem Kuliah Fail Kuliah Data Pensyarah
Data Dewan Kuliah
Data Pelajar
HEP Sistem Aktitvi
Pelajar
Fail Aktiviti Data Aktiviti
Data Pelajar
Bendahari Sistem Biasiswa Fail
Biasiswa
Data Pelajar
Data Penaja
Sistem berasaskan fail
Setiap aturcara menakrifkan dan menguruskan datanya
sendiri. 7
8. Kelemahan Sistem Fail Tradisional
• Kompleks
– Bilangan data meningkat dgn penambahan rekod.
– Data diperolehi dari pelbagai sumber: peribadi, dalaman, luaran.
• Data bertaburan (Terpisah dan Terpencil).
– Masa capaian
– Pertindihan data
– Susunan Data (kekurangan integrasi data)
• Keanjalan data
– Sukar untuk mewakili data pada pandangan pengguna
• Keselamatan, kualiti dan integriti data.
8
9. Menggunakan Pangkalan Data
– Data boleh dikongsi
– Secured data
– Data mudah dicapai
– Mengurangkan pertindihan
data
– Mengurangkan masa
membangunkan aplikasi
– Mengurangkan masa carian
– Mengeluarkan laporan
– Meningkatkan integriti dan
penyelarasan data
9
10. Sistem Pangkalan Data
HEA Sistem Kuliah
Data Pensyarah
Data Dewan
Kuliah
Data Pelajar
HEP Sistem Aktitvi
Pelajar
DBMS
Data Aktiviti
Bendahari Sistem Biasiswa Data Penaja
Banyak program dan pengguna berkongsi data
10
11. File Processing Versus Databases
• Bagaimana aplikasi pangkalan data dan pemprosesan fail
berbeza dalam menyimpan data?
11
13. • Perpustakaan: Pinjaman dan carian buku
• Supermarket: Pembelian brg2
• Bank: semua transaksi
• Airlines: tempahan, jadual
• Universities: pendaftaran, gred
• Sales: customers, products, purchases
• Online retailers: order tracking, customized recommendations
• Manufacturing: production, inventory, orders, supply chain
• Human resources: employee records, salaries, tax deductions
– Databases touch all aspects of our lives
Contoh Database
13
14. Sistem Pengurusan Pangkalan Data
(DBMS)
• Antara muka perisian antara pengguna dan pangkalan data.
Personal computer, midrange
server, mainframe
IBM CorporationDB2
Personal computer, midrange
server, mainframe
IBM CorporationInformix
ServerMicrosoft CorporationSQL Server
Personal computer, midrange
server, PDA
Sybase Inc.Sybase
Personal computer, midrange
server, mainframe, PDA
Oracle CorporationOracle
Personal computer, midrange
server, mainframe
Computer Associates
International, Inc.
Ingres
Personal computer, server, PDAMicrosoft CorporationAccess
Computer TypeManufacturerDatabase
14
15. Fungsi DBMS
• Pembangunan database (Database Development)
– Defining and organizing the content, relationships, and structure of the data
needed to build a database.
• Database Application Development
– Using DBMS to create prototypes of queries, forms, reports, Web pages.
• Database Maintenance
– Using transaction processing systems and other tools to add, delete, update,
and correct data.
• Database interrogation
5-1515
18. 1. Data Planning
• Develop an enterprise model that defines the basic
business process of the enterprise.
• Output:-
– Enterprise model of business process and documentation
5-18
DatabaseDevelopmentProcess
18
19. 2. Requirement Specification
• Define the information needs of end users in
a business process.
• Output:-
– Descriptions of users’ needs may be represented in natural language or
using the tools of a particular design methodology
5-19
DatabaseDevelopmentProcess
19
20. 3. Conceptual Design
• An abstract model of a database from the user or business
perspective.
• A map of concepts and their relationships.
• Expresses all information requirements in the form of a high level
model.
• It describes the things of significance to an organization (entity
classes), about which it is inclined/influence to collect information,
and characteristics of (attributes) and associations between pairs
of those things of significance (relationships).
• Example: Entity-relationship modeling
5-20
DatabaseDevelopmentProcess
20
22. Conceptual Design (cont…)
• Entity-relationship modeling: The process of designing a
database by organizing data entities to be used and
identifying the relationships among them.
• Entity-relationship (ER) diagram: Document that shows data
entities and attributes and relationships among them.
22
27. Entity Relationship Diagram
• Attribute: A property that describes some aspect of entity.
– i.e. attributes describes an entity’s characteristics.
Student
ID
Name
Residential Hall
Programme
Sex
Religion
Contact No
Place of Birth
Date of Birth
27
29. Entity Relationship Diagram
• Relationships: The conceptual linking of entities in a
database.
• The number of entities in a relationship is the degree of
the relationship. Relationships between two items are
common and are called binary relationships.
29
31. Binary Relationships
• There are three types of binary relationships:
– 1:1 (one-to-one) relationship: a single-entity instance of one type is
related to a single-entity instance of another type.
– 1: M (one-to-many) relationship: a single-entity instance of one type
is related to many-entity instance of another type.
– M:M (many-to-many) relationship: a single-entity instance of one
type is related to many-entity of another type and vice versa.
31
33. 4. Logical Design
• Translates the conceptual models into the data model of
a DBMS.
• The user’s view of the data and the software programs
that process that data in a database management
system.
• Output is logical data models, i.e.
– Relational, network, hierarchical, object-oriented or
multidimensional models.
5-33
DatabaseDevelopmentProcess
33
34. Data Model
• Rules and standards that define how
database organizes data and how
users view organization of data.
• The three most common data models
are hierarchical, network, and
relational.
• Other types of data models include
multidimensional, object-relational,
hypermedia, embedded, and virtual.
34
35. Hierarchical Database Model
• Structures data into an inverted “tree” in which each
record contains two elements, a single root or master
field, often called a key, and a variable number of
subordinate fields.
• Advantage is the speed and efficiency with which it can be
searched for data.
• problems:
– Access to data in this model is predefined by the database
administrator before the programs that access the data are
written.
– Programmers must follow the hierarchy established by the data
structure.
35
37. Network Database Model
• Data model that creates
relationships among data in
which subordinate records
can be linked to more than
one data element.
• Many-to-many relationships
• Used in some mainframes
DBMS packages
5-3737
38. Relational Database Model
• Most widely used structure
• Stores data in tables that consist of rows and columns
– Each row (record) has primary key
– Each column (column) has unique name
• Stores data relationships.
– Can relate data in one file with data in another, if both files share
a common data element.
• Uses specialized terminology:
5-3838
41. Advantages and Disadvantages of Logical
Data Models
Model Advantages Disadvantages
Hierarchical
database
Searching is fast and efficient. Access to data is predefined by exclusively
hierarchical relationships, predetermined by
administrator. Limited search/query
flexibility. Not all data are naturally
hierarchical.
Network Many more relationships can
be defined. There is greater
speed and efficiency than with
relational database models.
This is the most complicated database model
to design, Implement, and maintain. Greater
query flexibility than with hierarchical model,
but less than with relational model.
Relational database Conceptual simplicity; there
are no predefined relationships
among data. High flexibility in
ad-hoc querying. New data
and records can be added
easily.
Processing efficiency and speed are lower.
Data redundancy is common, requiring
additional maintenance.
41
42. Object-Oriented Database (OODB)
• A database model in which information is represented in the form
of objects.
• Object is item that contains data, as well as actions that read or
process data.
• Supports complex data types more efficiently than relational
databases.
• Often uses object query language (OQL) in object-oriented
database management systems (OODBMS).
• Advantages:
– Can store more types of data.
– Can access data faster
42
43. 5. Physical Design
• Determines the data storage structures and access methods.
– How data are to be physically stored and accessed on storage devices?
• Output is physical data models storage representation and access
methods.
– Layout that shows how a database is actually arranged on storage devices.
– The plan for the actual, physical arrangement and location of data in the
direct access storage devices (DASDs) of a database management system.
DatabaseDevelopmentProcess
43
44. Application Development
• Use DBMS software development tools to develop
custom application programs
– Not necessary to develop detailed data-handling
procedures using conventional programming
languages
– Can include data manipulation language (DML)
statements that call on the DBMS to perform
necessary data handling
– This specifications is stored inside a data dictionary or
a metadata repository.
DBMSFunction
44
45. Data Dictionary
• Known as metadata
repository, a
"centralized repository
of information about
data such as meaning,
relationships to other
data, origin, usage, and
format.
Contains data about each file in database and each
field within those files.
45
46. The Hierarchy of Data
• Refers to the systematic organization of data, often in a
hierarchical form.
• A hierarchy is an arrangement of items (objects, names,
values, categories, etc.) in which the items are represented as
being "above," "below," or "at the same level as" one another.
46
47. The Hierarchy of Data
Database contains files, file contains records, record contains fields, field contains
characters, characters are represented by bytes and bits.
47
48. The Hierarchy of Data
Database
Bit Byte Field Record File
+
Metadata
+
Index
+
Application metadata
Character
48
49. Field
• A data field holds a single fact.
• Combination of one or more characters.
• Example: “October 18, 2010". This can be
treated as a single date field (eg birthdate),
or 3 fields, namely, month, day of month and
year.
• Smallest unit of data user accesses
– Field size defines the maximum number of
characters a field can contain
– Field name uniquely identifies each field
– Data type specifies kind of data field contains
49
50. Data Type
• A classification identifying one of various types of
data
– Text (also called alphanumeric) — letters, numbers, or
special characters
– Numeric - numbers only
– AutoNumber - unique number automatically assigned to
each new record
– Currency - dollar and cent amounts or numbers
containing decimal values
– Date - month, day, year, and sometimes time
– Memo - lengthy text entries
50
51. Data Type (cont…)
• Yes/No (also called Boolean) — only the values Yes
or No (or True or False)
• Hyperlink - Web address that links to document or
Web page
• Object - OLE Object (Object Linking and
Embedding) or BLOB (Binary Large Object) -
photograph, audio, video, or document created in
other application such as word processing or
spreadsheet.
51
52. Record
• A record (tuple) is a collection of related fields or a
group of related fields.
• An Employee record may contain a name field(s),
address fields, birthdate field and so on.
• Key field, or primary key is a field or combination of
fields that uniquely identifies each record in the
table.
52
53. Primary Key
• Uniquely identifies each record.
• Cannot be repeated.
• Can be an auto number.
• i.e. student id, i/c number, staff id, reference no.
53
54. File / Table
• A file is a collection of related records.
• If there are 100 employees, then each employee
would have a record (e.g. called Employee Personal
Details record) and the collection of 100 such
records would constitute a file (in this case, called
Employee Personal Details file).
• Files are integrated into a database. This is done
using a Database Management System.
54
55. Data File / Table
• Collection of related records stored on disk
key
field
records fields
22 Fifth Avenue
P.O. Box 45
15 Duluth Street
33099 Clark Street
1029 Wolf Avenue
Address
Auburn
Clanton
Prattville
Montgomery
Montgomery
City
ALWeinbergJonah3928
ALMarcus4872
ALValesquezAdrian3376
ALMurrayShannon2928
ALVandenbergDonna2295
StateLast NameFirst NameMember ID
Green
55
56. Database Maintenance
• Accomplished by transaction processing systems
and other applications, with the support of the
DBMS.
– Done to reflect new business transactions and other
events.
– Updating and correcting data, such as customer
addresses.
5-56
DBMSFunction
56
57. Database Interrogation
• Database interrogation is where the end users use a
DBMS features such as Query, Report, or entering and
changing data in database.
• Query language
– Immediate response to ad hoc data requests
– i.e. SQL, QBE
• Report generator
– Quickly specify a format for information you want to
present as a report.
• Form
5-57
DBMSFunction
57
58. Structured Query Language (SQL)
• A database computer language designed for managing data in
relational database management systems (RDBMS).
• Allows you to manage, update, and retrieve data
• Has special keywords and rules included in SQL statements
SQL statement
SQL statement results
58
59. Query
• Request for specific data from
a database.
• Query language consists of
simple, English-like statements
that allow users to specify data
to display, print, or store.
Step 1. Select the fields you want
to display in the resulting query.
Step 2. Assign a name to the
query, so you can open it later.
Step 3. View query on the screen.
59
60. Query by Example (QBE)
• A database query language for relational databases
• Program retrieves records that match criteria entered in form fields
• Has a graphical user interface that assists users with retrieving data
Query by example screen
criteria
Query results
60
61. Report Generator
• Also called report writer.
• Allows user to design a report on screen, retrieve data into
report design, then display or print reports.
61
62. Form
• Window on screen that
provides areas for
entering or changing
data in database.
• Used to retrieve and
maintain data in a
database.
• Form that sends data
across network or
Internet is called e-form,
short for electronic form.
62
64. Introduction to MS Access 2013
• Microsoft Access 2013 is a database creation and
management program.
• MS Access 2013 is a relational model database that is
commonly used in commercial database.
• Saving a database in MS Access 2013 is done at the
beginning of the database.
• MS Access files extension:
– MS Access 97 – 2003 ~ *.mdb
– MS Access 2007 – 2013 ~ *.accdb
5-6464
65. MS Access 2013 Objects
• Databases in Access are composed of four
objects: tables, queries, forms, and reports.
• Other objects include: macros and modules
5-6565
66. MS Access 2013 Tables
• All data in Access is stored in tables, which puts
tables at the heart of any database.
• Tables are organized into vertical columns and
horizontal rows.
• In Access, rows and columns are referred to
as records and fields.
5-6666
67. MS Access 2013 Forms
• Forms are used for entering, modifying,
and viewing records.
• Forms are used to guide people into entering data
correctly.
• Forms allow
to both add data
to tables and
view data that
already exists.
5-6767
68. MS Access 2013 Queries
• Queries are a way of searching for and compiling
data from one or more tables.
• It contains:
– A question about the database
– An answer to the question
– Selected records answering the query
68
69. MS Access 2013 Reports
• Reports offer the ability to present your data in
print.
• MS Access offers the ability to create a report
from any table or query.
5-6969
70. MS Access 2013 Objects
• Every piece of data a query, form, or report uses is
stored in one of your database tables
• Forms allow to both add data to tables
and view data that already exists.
• Reports present data from tables and also from
queries which, in turn, search for and analyze data
within those same tables.
5-7070
71. MS Access 2013 Objects (cont…)
• When conducted the search, you were entering
your search terms into a form that, in turn,
created and ran a query based on your request.
• When the query finished searching the
database's tables for records that matched your
search, you were shown a report that drew
information from the query and the related tables.
5-7171