Download presentation
Presentation is loading. Please wait.
Published byAdela Walsh Modified over 9 years ago
1
Introduction to Database Management System 電機三 趙上鋒
2
Outline What is DBMS? What can DBMS do? How to design a database? How to use DBMS? Conclusion Reference
3
What is DBMS?
4
Data v.s. Information Data Anything stored without summarized or analyzed. Information Data that has been proceeded to be meaningful for users.
5
Example Data Information
6
Database Stores organized data so that you can query from it or update it. Like an electrical shelf to put data with organization.
7
From user to data Teacher (user) Application x Database data Student (user) Application x
8
What is DBMS? Database Management System DBMS is software to store and manage data, so applications don’t have to worry about them. Like a person who search the dictionary for you.
9
Relation between App & DBMS Teacher (user) Application x data Student (user) Application x View1 View2 Conceptual schema Physical schema DBMS
10
What can DBMS do?
11
DBMS can Do These… Store huge amount of data ( eg. 100+GB ) Store data for long period of time Manage data on permanent storage. Efficient database operation B+ Tree indexing Hash-based indexing Allow people to query & update data Support query language.
12
More Requirement Protect from unauthorized access Security! Protect from system crash Crash recovery Support many users to access the database at the same time Concurrency control Allow administrator to easily change data schema Protect from incorrect input
13
If we don’t use DBMS Applications have to stores data as files 32-bit addressing (5GB) is insufficient to address 100GB+ data file Write special code to: support different queries protect data from multiple users and concurrent access protect against data loss / corruption as result of system crashes
14
If we don’t use DBMS (cont’d) Other issues: Rewrite applications when data schema changes Password-based authorization is insufficient Optimize applications for efficient access and query Easier to use a DBMS to handle these issuse!
15
How to design a database
16
Data Model A data model is a collection of concepts for describing data. Entity-relation (ER) model Proposed by Peter Chen (BS NTU EE ‘68) in 1976 popular for conceptual design Relational model Object-oriented model A schema is a description of a particular collection of data in a given data model. Eg. How to describe a book?
17
Some example for ER-modal user idpassword order num Entity set key attribute relation book ISBN name author price
18
Relational Model Most widely used today Microsoft SQL Server Oracle MySQL SyBase IBM DB2 Microsoft Office Access
19
Why People Like It Simple Each relation is represented as a table of rows and columns Easy to understand Ease of expressing complex query (using SQL) on the data Efficient query evaluation (using query optimization)
20
Example of Relation A relation has two parts: Relational Schema defines column heads of the table. Relational Instance contains the data rows (called tuples or records) of the table. ISBNnameauthorprice 1234567890 羊肉爐不是故意的 LogyDog200 0780785678 奼紫嫣紅牡丹亭:四百年青春之夢白先勇 380 0025201179 孽子白先勇 270
21
Example of Relation Field Also called an attribute or a column Key a set of minimal fields that can uniquely identify a tuple in a relation ISBNnameauthorprice 1234567890 羊肉爐不是故意的 LogyDog200 0780785678 奼紫嫣紅牡丹亭:四百年青春之夢白先勇 380 0025201179 孽子白先勇 270
22
Convert from ER-Model to Relational Model idpassword user id password order num book ISBN name author price ISBNnameauthorprice idISBNnum userbook order
23
How to use DBMS?
24
SQL Structured Query Language Developed by IBM (system R) in the 1970s Current standard: SQL-99 DDL: Data Definition Language DML: Data Manipulation Language
25
SQL Basic Commands DDL create table: create a table drop table: delete a table alter table: alter a field in a table DML insert: add a record delete: delete a record update: change field values in a record select: query data satisfying some condition
26
Example of create table & drop table create table book( ISBN integer, name char(255), author char(127), price integer, primary key(ISBN) ) drop table book ISBNnameauthorprice
27
Example of alter table alter table book add m_price integer alter table book drop m_price ISBNnameauthorprice m_ price
28
Example of insert insert into book( ISBN, name, author, price ) values ( 1234567890, “ 羊肉爐不是故意的 ”, “LogyDog”, 200 ) ISBNnameauthorprice ISBNnameauthorprice 1234567890 羊肉爐不是故意的 LogyDog200
29
Example of delete delete from book where author = ‘ 白先勇 ’ ISBNnameauthorprice 1234567890 羊肉爐不是故意的 LogyDog200 0780785678 奼紫嫣紅牡丹亭:四百年青春之夢白先勇 380 0025201179 孽子白先勇 270
30
Example of update update book as b set b.name = ‘ 羊肉爐不是故意的 ’ where b.author = ‘LogyDog’ update book as b set b.price = b.price * 0.9 ISBNnameauthorprice 1234567890 羊肉爐是故意的 LogyDog200 0780785678 奼紫嫣紅牡丹亭:四百年青春之夢白先勇 380 0025201179 孽子白先勇 270 羊肉爐不是故意的 180 342 243
31
Example of select select book as b where b.price<300 and author=‘ 白先勇 ’ ISBNnameauthorprice 1234567890 羊肉爐不是故意的 LogyDog200 0780785678 奼紫嫣紅牡丹亭:四百年青春之夢白先勇 380 0025201179 孽子白先勇 270
32
Conclusion
33
Reference Database Management System, 3 rd Ed., by R&G http://mll.csie.ntu.edu.tw/course/database/in dex.html - by Hao-hua Chu http://mll.csie.ntu.edu.tw/course/database/in dex.html Computer Science -- An Overview, 7 th Ed, by J. Glenn Brookshear
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.