Upload
others
View
15
Download
1
Embed Size (px)
Citation preview
204222 - Fundamentals of Database Systems
Chapter 1
Databases and Database Users
Adapted for 204222
by Areerat Trongratsameethong
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Chapter 1 Outline
• Introduction• An Example• Characteristics of the Database Approach• Actors on the Scene• Workers behind the Scene• Advantages of Using the DBMS Approach• A Brief History of Database Applications• When Not to Use a DBMS
2
Overview• Traditional database applications
– Store textual or numeric information– ฐานขอมลแบบดงเดมใชจดเกบขอมลทอยในรปของอกขระ และตวเลข
• Multimedia databases– Store images, audio clips, and video streams digitally– ฐานขอมลสอผสม (ฐานขอมลมลตมเดย) ใชจดเกบขอมลทอยในรป
ของ รปภาพ เสยง และวดโอ
• Geographic information systems (GIS) – Store and analyze maps, weather data, and satellite
images– ระบบสารสนเทศภมศาสตร ใชจดเกบและวเคราะหแผนท ขอมล
เกยวกบอากาศ และภาพถายจากดาวเทยม 3
Overview (cont'd.)• Data warehouses and online analytical processing
(OLAP) systems – Extract and analyze useful business information
from very large databases – Support decision making– Data Warehouses และ OLAP ใชวเคราะหขอมลจาก
ฐานขอมลขนาดใหญ เพอเปนประโยชนทางธรกจ และชวยในการ
ตดสนใจในการดาเนนธรกจ
• Real-time and active database technology – Control industrial and manufacturing processes– ฐานขอมลทใชควบคมเครองจกร และขบวนการตางๆในโรงงาน
แบบ Real-time (แบบ ทนททนใด)4
Introduction• Database
– ฐานขอมลคอ ททใชสาหรบจดเกบขอมลทมความสมพนธกน
– ขอมลคอ ขอเทจจรงทมความหมายชดเจนทถกบนทก หรอจดเกบ
– Database มคณสมบตดงตอไปน • นาเสนอบางมมมองของความเปนจรงทเกดขน บางครงเรยกวา
Miniworld หรอ Universe of Discourse (UoD)• ขอมลทจดเกบมความหมายทสอดคลองกนอยางเหนยวแนน
และไปในทศทางเดยวกน• สรางขนเพอวตถประสงคทเฉพาะเจาะจง
• Example of a large commercial database– ตวอยางฐานขอมลขนาดใหญในวงการธรกจคอ ฐานขอมลของ
Amazon.com5
Introduction (cont'd.)
• Database Management System (DBMS) – DBMS คอทรวมของโปรแกรมทสรางขนเพอใหผใชสามารถสราง
และจดการฐานขอมล
– ในการสรางฐานขอมล จะตองกาหนดชนดของขอมล (Data Type) โครงสรางของขอมล (Structure) และขอจากด
(Constraint) ของขอมลทจะจดเกบในฐานขอมล
• Meta-data– Meta-data คอ คานยาม หรอคาอธบายขอมลทอยในฐานขอมล
ซงถกจดเกบโดย DBMS ในรปแบบของ Database Catalog หรอ Data Dictionary
6
Introduction (cont'd.)• Manipulating a database
– การจดการขอมลในฐานขอมล เชน การสบคนขอมล การปรบปรง
ขอมล การสรางรายงานตางๆ
• Sharing a database – DBMS อนญาตใหผใชงานหลายคน หรอโปรแกรมหลาย
โปรแกรม เขาใชงานฐานขอมลพรอมๆกนได
• Application program – โปรแกรมประยกตสามารถเขาใชงานฐานขอมลโดยการสงคาสง
สบคนขอมล (query) ไปยง DBMS
7
Introduction (cont'd.)• Transaction
– Transaction ประกอบดวยสวนของการดาเนนการ เพอบรหารจดการฐานขอมล ทอาจทาใหขอมลในฐานขอมลบางสวนถกอาน หรอถกเขยน
• Protection includes: การปองกนฐานขอมล ประกอบดวย
– System protection: ปองกนจากความผดปกต หรอความเสยหาย เชน ดสคเกดความเสยหาย เปนตน
– Security protection: ปองกนจากผใชทไมไดรบอนญาต หรอจากการบกรกเพอทาใหขอมลเสยหาย
• Maintain the database system – ระบบฐานขอมลเอออานวยใหมการบารงรกษาระบบ และปรบเปลยน
ขอมลไดทกเวลา เนองจากความตองการของผใชระบบมการเปลยนแปลงไดตลอดเวลา
8
9
An Example
• UNIVERSITY database – Information concerning (เกยวของกบ) students,
courses, and grades in a university environment
• Data records– STUDENT – COURSE– SECTION – GRADE_REPORT – PREREQUISITE
10
An Example (cont'd.)
• Specify structure of records of each file by specifying data type for each data element
• กาหนดโครงสรางของ records ของแตละ file โดย
การ กาหนด data type สาหรบขอมลแตละ
element– String of alphabetic characters– Integer– Etc.
11
An Example (cont'd.)
• Construct UNIVERSITY database– Store data to represent each student, course,
section, grade report, and prerequisite as a record in appropriate file
• Relationships among the records: ความสมพนธ
ระหวาง records• Manipulation involves querying and updating:
การจดการขอมลเกยวของกบการสอบถามขอมล หรอสบคนขอมล
(query) และการปรบปรงขอมล
12
An Example (cont'd.)• Examples of queries:
– Retrieve the transcript– List the names of students who took the section of
the ‘Database’ course offered in fall 2015 and their grades in that section
– List the prerequisites of the ‘Database’ course
• Examples of updates:– Change the class of ‘Smith’ to sophomore– Create a new section for the ‘Database’ course for
this semester– Enter a grade of ‘A’ for ‘Smith’ in the ‘Database’
section of last semester 13
An Example (cont'd.)
• Phases for designing a database: – Requirements specification and analysis– Conceptual design– Logical design – Physical design จะไดเรยนในบทถดๆไป
14
15
16
Characteristics of the Database Approach
ววฒนาการของการจดเกบขอมล
• Traditional file processing– การจดเกบขอมลแบบดงเดม จดเกบในรปของ file โดยทผใชแตละคน
กาหนดขอมล และจดเกบขอมลของตวเองสาหรบใชใน software application ทเฉพาะเจาะจงของแตละคน
• Database approach– การจดเกบขอมลในรปแบบของฐานขอมล โดยทจดเกบขอมลไวท
เดยวกน และผใชหลายๆคนสามารถเขาถง และใชขอมลรวมกนได17
Characteristics of the Database Approach (cont'd.)
• Main characteristics of database approach: ลกษณะสาคญของการจดเกบขอมลในรปแบบของฐานขอมล
– Meta-data: Data about data คอ คานยาม หรอคาอธบายขอมลทจดเกบอยในฐานขอมล ถกจดเกบไวในฐานขอมลเชนเดยวกน (ขอมลทใชอธบายเกยวกบตวขอมลเอง)
– ขอมล และโปรแกรม ถกจดเกบแยกออกจากกน
– สนบสนนขอมลในหลายมมมอง คอ ขอมลสาหรบผใชตางแผนก สามารถเหนขอมลตางมมมองกนได
– ผใชหลายคน สามารถใชขอมลรวมกน และขอมลสามารถถกประมวลผลโดยผใชหลายๆคนไดพรอมกน
18
Self-Describing Nature of a Database System
• Database system contains complete definition of structure and constraints: ระบบฐานขอมลประกอบดวย การกาหนดโครงสราง และขอจากดของขอมล
• Meta-data (Data about data): ใชอธบายโครงสรางของฐานขอมล
• Database catalog used by: Database catalog ถกใชโดย
– DBMS software – Database users
19
Insulation Between Programs and Data
• Program-data independence: โปรแกรม และขอมลแยก
อสระจากกน
– โครงสรางของขอมลถกจดเกบไวใน DBMS Catalog ซงแยกออกจากตวโปรแกรมทตองการเขาถงขอมล ทาใหการเปลยนแปลงโครงสราง
ขอมลไมกระทบกบโปรแกรม (โปรแกรมไมจาเปนตอง compile ใหม) – Operations specified in two parts: การดาเนนการกบขอมล
สามารถทาผาน
• Interface: โดยการระบ ชอ operation, arguments, และ data types ของ arguments
• Operation สามารถกแกไขไดโดยไมมผลกระทบกบ interface20
Data Abstraction• Data abstraction
– โปรแกรม และขอมล เปนอสระจากกน
– โปรแกรม และ operation เปนอสระจากกน
• Conceptual representation of data– ขอมลถกนาเสนอในรปของ conceptual คอ ขอมลไมไดแสดง
รายละเอยดของการจดเกบ หรอไมไดแสดงรายละเอยดของ operations ทใชดาเนนการกบขอมลวาตดตงอยางไร
• Data model – Data Model คอรปแบบของขอมลทใชในการนาเสนอขอมลใน
รปแบบ conceptual 21
Support of Multiple Views of the Data
• View: ผใชรบรขอมลในมมมองทแตกตางกนได
– เปน Subset ของ database
– ประกอบดวยขอมลเสมอนจรงทไดมาจากขอมลทจดเกบอยใน
ฐานขอมล แตขอมลทอยในรปแบบของ view ไมไดจดเกบจรงใน
ฐานขอมล
• Multiuser DBMS – ผใชสามารถเขาถงขอมลจาก application ทแตกตางกนได
– DBMS มสงอานวยความสะดวกสาหรบการกาหนด views ทแตกตางกนให users ทหลากหลายได
22
Sharing of Data and Multiuser Transaction Processing
• Allow multiple users to access the database at the same time: อนญาตให user หลายๆคนเขาถงขอมลในฐานขอมลใน
เวลาเดยวกนได
• Concurrency control software: software ทใชควบคม
การทางานพรอมๆกน
– Concurrency control software ชวยทาใหมนใจไดวา ผใชหลายๆคนทพยายามทจะปรบปรงขอมลในเวลาเดยวกน สามารถควบคมการปรบปรงขอมลให
ถกตองตามความตองการได สงผลใหการปรบปรงขอมลมความถกตอง
• Online transaction processing (OLTP) application: สนบสนนโปรแกรมทประมวลผลขอมลแบบ online
23
Sharing of Data and Multiuser Transaction Processing (cont'd.)
• Transaction – เปนหวใจสาคญของ database applications– ขบวนการทสามารถดาเนนการกบขอมลทจดเกบอยในหนง
ฐานขอมล หรอหลายฐานขอมลได
– Isolation property (คณสมบต): แตละ transaction จะถกดาเนนการแยกจาก transaction อนๆ
– Atomicity property: หากมการดาเนนการกบขอมล ตองดาเนนการใหเสรจสมบรณ หากดาเนนการไมสมบรณ ตองคนสภาพเดมของขอมล
Transaction ประกอบดวยสวนของการดาเนนการ เพอบรหารจดการฐานขอมล ทอาจทา
ใหขอมลในฐานขอมลบางสวนถกอาน หรอถกเขยน 24
Actors on the Sceneคนทางานเบองหนา
• Database administrators (DBA) are responsible for: DBA ทาหนาท
– กาหนดสทธในการเขาถงขอมลในฐานขอมล
– ผประสานงาน และผดแลการใชฐานขอมลของผ ใช
– จดหาทรพยากรดาน software และ hardware ทสนบสนนการใชงาน
ฐานขอมล
• Database designers are responsible for: ทาหนาท
– กาหนดขอมลทจะจดเกบในฐานขอมล
– เลอกโครงสรางขอมลทเหมาะสมทจะใชสาหรบนาเสนอขอมล และจดเกบ
ขอมล25
Actors on the Scene (cont'd.)• End users: บคคลทเขาใชงานฐานขอมล
– ประเภทของ End Users• Casual end users: user ทใชงานปกตทวไป• Naive or parametric end users: user เฉพาะ เชน
Bank Teller, Reservation Agency • Sophisticated end users: user ทตองการ การ
ประมวลผลทซบซอน เชน นกคณตศาสตร นกวเคราะหธรกจ• Standalone users: user ทใชงานคนเดยว เชน
โปรแกรมสาเรจรปตางๆ เชน โปรแกรมบญช เปนตน
• System analysts– เกบรวบรวม และวเคราะหความตองการของผใช
• Application programmers – สรางโปรแกรมตามความตองการของผใช
26
Workers behind the Sceneคนทางานเบองหลง
• DBMS system designers and implementers– ออกแบบ และตดตง DBMS software package
• Tool developers– ออกแบบ และตดตงเครองมอ (tools) ตางๆทชวยสนบสนนการใช
งานฐานขอมล
• Operators and maintenance personnel– Run โปรแกรม และบารงรกษา hardware and software
สาหรบระบบฐานขอมล
27
Advantages of Using the DBMS Approach• Controlling redundancy: สามารถควบคมความซาซอนของ
ขอมลได โดยการทา– Data normalization – Denormalization: ในบางครงกจาเปนทจะตองทา
Denormalization (จดเกบขอมลซาซอน) เพอเพมความเรวในการสบคนขอมล
• Restricting unauthorized access: สามารถกาหนดสทธในการเขาถงขอมล เพอปองกนความเสยหายทจะเกดขนจากผ ทไมมสทธ
– ม subsystem ทใชสาหรบกาหนดความปลอดภยของขอมล และกาหนดสทธในการเขาใชขอมลของผใช
– Privileged software: ม software ทใชจดการสทธ
(authority) ตางๆ
28
Advantages of Using the DBMS Approach (cont'd.)
• Providing persistent storage for program objects: สามารถจดเกบ object แบบถาวรได
– Object ทมความซบซอนใน C++ ทอยใน memory ขณะท run โปรแกรม สามารถถกจดเกบอยางถาวรใน object-oriented Database
– Impedance mismatch problem• Object-oriented database systems typically
offer data structure compatibility: OODB คอสญลกษณของการเสนอโครงสรางขอมลทเขากนได (ซงมโครงสรางทแตกตางจาก Relational Database)
29Impedance mismatch problem: ปญหาความเขากนไมได
Advantages of Using the DBMS Approach (cont'd.)
• Providing storage structures and search techniques for efficient query processing: มโครงสรางของททใชจดเกบขอมล และเทคนคในการคนหาขอมล เพอ
ประสทธภาพในการคนหาขอมลไดเรวขน โดยมเทคนคตางๆดงตอไปน
– Indexes– Buffering and caching– Query processing and optimization
30
Advantages of Using the DBMS Approach (cont'd.)
• Providing backup and recovery– Backup and recovery (การกขอมล หรอคนสภาพขอมล)
subsystem of the DBMS is responsible for recovery
• Providing multiple user interfaces– Graphical user interfaces (GUIs)
• Representing complex relationships among data– May include numerous varieties of data that are
interrelated in many ways: สามารถนาเสนอความสมพนธของ
ขอมลทมความหลากหลาย และเกยวของสมพนธกนหลายๆทาง31
Advantages of Using the DBMS Approach (cont'd.)
• Enforcing integrity constraints– Referential integrity constraint
• Every section record must be related to a course record
– Key or uniqueness constraint• Every course record must have a unique value for
Course_number
– Business rules– Inherent rules of the data model: กฎทสบทอดมาจาก
data model เชน ความสมพนธระหวางสอง entities
32
Advantages of Using the DBMS Approach (cont'd.)
• Permitting inferences (การอนมาน การสรป) and actions using rules– Deductive database systems
• Provide capabilities for defining deduction rules• Inferencing new information from the stored database
facts• e.g. Create new student must under the defined rules
– Trigger • Rule activated (กระตน) by updates to the table
– Stored procedures• More involved procedures to enforce rules
33
Advantages of Using the DBMS Approach (cont'd.)
• Additional implications of using the database approach– Reduced application development time: ชวยลดเวลา
ในการพฒนาโปรแกรม
– Flexibility: มความยดหยน
– Availability of up-to-date information: ทาใหขอมลเปน
ปจจบน
– Economies of scale: ประหยดคาใชจาย
34
A Brief History of Database Applications• Early database applications using hierarchical and
network systems– A data model in which the data is organized into a tree-like
structure. The data is stored as records which are connected to one another through links.
35Reference: http://wps.prenhall.com/wps/media/objects/14071/14409392/Learning_Tracks/Ess10_CH05_LT3_Hierarchical_and_Network_Data_Models.pdf
A Brief History of Database Applications
• Providing data abstraction and application flexibility with relational databases– Separates physical storage of data from its
conceptual representation – Provides a mathematical foundation (พนฐานในการ
คานวณทางคณตศาสตร) for data representation and querying
36
A Brief History of Database Applications (cont'd.)
• Object-oriented applications and the need for more complex databases– Used in specialized applications: engineering design,
multimedia publishing, and manufacturing systems
• Interchanging data on the Web for e-commerce using XML: การแลกเปลยนขอมลบน Web สาหรบ
e-commerce โดยใช eXtensible Markup Language (XML)– XML primary standard for interchanging data among
various types of databases and Web pages
37
A Brief History of Database Applications (cont'd.)
• Extending database capabilities for new applications– Enterprise resource planning (ERP)– Customer relationship management (CRM)
• Databases versus information retrieval– Information retrieval (IR)
• Deals with books, manuscripts, and various forms of library-based articles
38
When Not to Use a DBMS• More desirable to use regular files for: เมอใดทไมตองใช
Database โดยทใช file ขอมลปกตแทน– Simple, well-defined database applications not
expected to change at all: ขอมลมโครงสรางทไมซบซอน และไมมการเปลยนแปลง
– Stringent, real-time requirements that may not be met because of DBMS overhead: ระบบทตองการความรวดเรวทไมสามารถรอไดจากการเสยเวลาทเกดจาก overhead ของ DBMS
– Embedded systems with limited storage capacity: ระบบฝงตวทมขอจากดของททใชจดเกบขอมล
– No multiple-user access to data: มผใชขอมลเพยงคนเดยว
39
Summary
• Database – Collection of related data (recorded facts)
• DBMS – Generalized software package for implementing
and maintaining a computerized database
• Several categories of database users• Database applications have evolved
– Current trends: IR, Web
40