Presentation is loading. Please wait.

Presentation is loading. Please wait.

CPSC-310 Database Systems

Similar presentations


Presentation on theme: "CPSC-310 Database Systems"— Presentation transcript:

1 CPSC-310 Database Systems
Professor Jianer Chen Room 315C HRBB Lecture #1

2 Two parts about database

3 Two parts about database
purpose Learn how to develop DB (database design) Understand how DB works (database principle)

4 Two parts about database
purpose After the study Learn how to develop DB (database design) Be able to develop DB Understand how DB works (database principle)

5 Two parts about database
purpose After the study Learn how to develop DB (database design) Be able to develop DB Understand how DB works (database principle) Know better about DB

6 Two parts about database
purpose After the study Learn how to develop DB (database design) Be able to develop DB necessary Understand how DB works (database principle) Know better about DB

7 Two parts about database
purpose After the study Learn how to develop DB (database design) Be able to develop DB Help develop better DB necessary Understand how DB works (database principle) Know better about DB

8 Two parts about database
purpose After the study Learn how to develop DB (database design) Be able to develop DB Help develop better DB necessary This course covers Understand how DB works (database principle) Know better about DB

9 Computer for Information Processing

10 Computer for Information Processing
General information processing: data are in computer (memory) and users run CPU to process the data.

11 Computer for Information Processing
General information processing: data are in computer (memory) and users run CPU to process the data. CPU Data in memory

12 Computer for Information Processing
General information processing: data are in computer (memory) and users run CPU to process the data. Information processing is involved in four components: CPU Data in memory

13 Computer for Information Processing
General information processing: data are in computer (memory) and users run CPU to process the data. Information processing is involved in four components: data structure, Data structure

14 Computer for Information Processing
General information processing: data are in computer (memory) and users run CPU to process the data. Information processing is involved in four components: data structure, basic operations Data structure +, –, ×, ⁄

15 Computer for Information Processing
Algorithm (ideas) General information processing: data are in computer (memory) and users run CPU to process the data. Information processing is involved in four components: data structure, basic operations, algorithm Data structure +, –, ×, ⁄

16 Computer for Information Processing
Algorithm (ideas) General information processing: data are in computer (memory) and users run CPU to process the data. Information processing is involved in four components: data structure, basic operations, algorithm, and programming language main(); { …… } Data structure +, –, ×, ⁄

17 Computer for Information Processing
Algorithm (ideas) General information processing: data are in computer (memory) and users run CPU to process the data. Information processing is involved in four components: data structure, basic operations, algorithm, and programming language. Example: programming with Java, C++ etc. main(); { …… } Data structure +, –, ×, ⁄

18 Database is just another model of information processing

19 Database is just another model of information processing
Then why study DB?

20 Database is just another model of information processing
Then why study DB? Much more data, regular data techs would be very inefficient: How should data be stored?

21 Database is just another model of information processing
Data in memory CPU Then why study DB? Much more data, regular data techs would be very inefficient: How should data be stored?

22 Database is just another model of information processing
Then why study DB? Much more data, regular data techs would be very inefficient: How should data be stored?

23 Database is just another model of information processing
(in disks) Then why study DB? Much more data, regular data techs would be very inefficient: How should data be stored?

24 Database is just another model of information processing
(in disks) Then why study DB? Much more data, regular data techs would be very inefficient: How should data be stored? Operations are simpler & more specific: How do we take advantage of it? π, σ, ρ, set ops, joins

25 Database is just another model of information processing
(in disks) Then why study DB? Much more data, regular data techs would be very inefficient: How should data be stored? Operations are simpler & more specific: How do we take advantage of it? New programming languages for the above. π, σ, ρ, set ops, joins SQL

26 Database is just another model of information processing
(in disks) Then why study DB? Much more data, regular data techs would be very inefficient: How should data be stored? Operations are simpler & more specific: How do we take advantage of it? New programming languages for the above. (ACID) Reliability, security, consistency, currency π, σ, ρ, set ops, joins SQL

27 Database is just another model of information processing
(in disks) Then why study DB? Much more data, regular data techs would be very inefficient: How should data be stored? Operations are simpler & more specific: How do we take advantage of it? New programming languages for the above. (ACID) Reliability, security, consistency, currency π, σ, ρ, set ops, joins SQL

28 How Should Data be Stored?
Large volume: cannot fit in memory, thus in general stored in disks;

29 How Should Data be Stored?
Large volume: cannot fit in memory, thus in general stored in disks; Regular files are not organized enough;

30 How Should Data be Stored?
Large volume: cannot fit in memory, thus in general stored in disks; Regular files are not organized enough; Hierarchical structure and network structure were considered, but became less popular;

31 How Should Data be Stored?
Large volume: cannot fit in memory, thus in general stored in disks; Regular files are not organized enough; Hierarchical structure and network structure were considered, but became less popular; Table structures (2-dimensional arrays) are currently the most popular model (relational model);

32 How Should Data be Stored?
How can everything be given by tables?

33 How Should Data be Stored?
How can everything be given by tables? Well, information consists of objects/items and relationships among items;

34 How Should Data be Stored?
How can everything be given by tables? Well, information consists of objects/items and relationships among items; An item has certain properties, which can be listed in a row. Thus, a collection of similar items can be given as a table, one row for an item;

35 How Should Data be Stored?
How can everything be given by tables? Well, information consists of objects/items and relationships among items; An item has certain properties, which can be listed in a row. Thus, a collection of similar items can be given as a table, one row for an item; A relationship can be given by listing each item group that satisfies the relationship;

36 How Should Data be Stored?
How can everything be given by tables? Well, information consists of objects/items and relationships among items; An item has certain properties, which can be listed in a row. Thus, a collection of similar items can be given as a table, one row for an item; A relationship can be given by listing each item group that satisfies the relationship; We will study how to represent real world things by tables

37 Table structures (terminologies)
Information is stored in tables (≡ relations); Each column of a table is an attribute, with an attribute name;

38 Table structures (terminologies)
Information is stored in tables (≡ relations); Each column of a table is an attribute, with an attribute name; A database is a collection of relations;

39 Table structures (terminologies)
Information is stored in tables (≡ relations); Each column of a table is an attribute, with an attribute name; A database is a collection of relations; An example table (Account): Account No. Balance Type 12345 20,520 checking 23456 1,000,000 CD 34567 26 savings 45678 7,023

40 Table structures (terminologies)
A relation schema gives the name of the relation and its attributes;

41 Table structures (terminologies)
A relation schema gives the name of the relation and its attributes; A database schema gives the schemas for all relations in the database;

42 Table structures (terminologies)
A relation schema gives the name of the relation and its attributes; A database schema gives the schemas for all relations in the database; Schemas affects how the data is stored;

43 Table structures (terminologies)
A relation schema gives the name of the relation and its attributes; A database schema gives the schemas for all relations in the database; Schemas affects how the data is stored; Database schemas are given and altered using database definition language (DDL);

44 Table structures (terminologies)
A relation schema gives the name of the relation and its attributes; A database schema gives the schemas for all relations in the database; Schemas affects how the data is stored; Database schemas are given and altered using database definition language (DDL); Only database administrator can use DDL.

45 What is a good DB schema?

46 What is a good DB schema? What is a good table structure? Fat or thin?

47 What is a good DB schema? What is a good table structure? Fat or thin?
More important: how can tables guarantee information consistency?

48 What is a good DB schema? What is a good table structure? Fat or thin?
More important: how can tables guarantee information consistency? There is a beautiful theory (functional dependency) for constructing a good database schema;

49 What is a good DB schema? What is a good table structure? Fat or thin?
More important: how can tables guarantee information consistency? There is a beautiful theory (functional dependency) for constructing a good database schema; We will study the theory.

50 Database is just another model of information processing
(in disks) Then why study DB? Much more data, regular data techs would be very inefficient: How should data be stored? Operations are simpler & more specific: How do we take advantage of it? New programming languages for the above. (ACID) Reliability, security, consistency, currency π, σ, ρ, set ops, joins SQL

51 Database is just another model of information processing
(in disks) Then why study DB? Much more data, regular data techs would be very inefficient: How should data be stored? Operations are simpler & more specific: How do we take advantage of it? New programming languages for the above. (ACID) Reliability, security, consistency, currency π, σ, ρ, set ops, joins SQL

52 What are the operations?

53 What are the operations?
Most DB operations are queries, e.g., “what is the balance of the account 12345?” which is involved in

54 What are the operations?
Most DB operations are queries, e.g., “what is the balance of the account 12345?” which is involved in * identify relations that are related to the queried information;

55 What are the operations?
Most DB operations are queries, e.g., “what is the balance of the account 12345?” which is involved in * identify relations that are related to the queried information; * search/organize the relations and collect the related information;

56 What are the operations?
Most DB operations are queries, e.g., “what is the balance of the account 12345?” which is involved in * identify relations that are related to the queried information; * search/organize the relations and collect the related information; * edit and output the queried information.

57 What are the operations?
Most DB operations are queries, e.g., “what is the balance of the account 12345?” which is involved in * identify relations that are related to the queried information; * search/organize the relations and collect the related information; * edit and output the queried information. Less often: modifications on relations;

58 What are the operations?
Most DB operations are queries, e.g., “what is the balance of the account 12345?” which is involved in * identify relations that are related to the queried information; * search/organize the relations and collect the related information; * edit and output the queried information. Less often: modifications on relations; These operations are given by data manipulation language (DML)

59 What are the operations?
The DML operations on relations can be implemented by the basic operations: * projection π and selection σ * set operations * joins * renaming ρ

60 What are the operations?
The DML operations on relations can be implemented by the basic operations: * projection π and selection σ * set operations * joins * renaming ρ There is a beautiful (mathematical) theory (relational algebra) that sets the foundation for these basic operations;

61 What are the operations?
The DML operations on relations can be implemented by the basic operations: * projection π and selection σ * set operations * joins * renaming ρ There is a beautiful (mathematical) theory (relational algebra) that sets the foundation for these basic operations; We will study this mathematical theory.

62 Database is just another model of information processing
(in disks) Then why study DB? Much more data, regular data techs would be very inefficient: How should data be stored? Operations are simpler & more specific: How do we take advantage of it? New programming languages for the above. (ACID) Reliability, security, consistency, currency π, σ, ρ, set ops, joins SQL

63 Database is just another model of information processing
(in disks) Then why study DB? Much more data, regular data techs would be very inefficient: How should data be stored? Operations are simpler & more specific: How do we take advantage of it? New programming languages for the above. (ACID) Reliability, security, consistency, currency π, σ, ρ, set ops, joins SQL

64 Structured Query Language (SQL)

65 Structured Query Language (SQL)
SQL provides both DDL and DML.

66 Structured Query Language (SQL)
SQL provides both DDL and DML. CREAT TABLE Accounts { accountNo INT, balance REAL, type CHAR(10) }

67 Structured Query Language (SQL)
SQL provides both DDL and DML. accountNo balance type Accounts CREAT TABLE Accounts { accountNo INT, balance REAL, type CHAR(10) }

68 Structured Query Language (SQL)
SQL provides both DDL and DML. accountNo balance type 12345 20,520 checking 23456 1,000,000 savings 34567 -26 Accounts CREAT TABLE Accounts { accountNo INT, balance REAL, type CHAR(10) }

69 Structured Query Language (SQL)
SQL provides both DDL and DML. accountNo balance type 12345 20,520 checking 23456 1,000,000 savings 34567 -26 Accounts CREAT TABLE Accounts { accountNo INT, balance REAL, type CHAR(10) } SELECT accountNo FROM Accounts WHERE type = 'savings' AND balance < 0;

70 Structured Query Language (SQL)
SQL provides both DDL and DML. accountNo balance type 12345 20,520 checking 23456 1,000,000 savings 34567 -26 Accounts CREAT TABLE Accounts { accountNo INT, balance REAL, type CHAR(10) } SELECT accountNo FROM Accounts WHERE type = 'savings' AND balance < 0; Output: 34567 

71 Database is just another model of information processing
(in disks) Then why study DB? Much more data, regular data techs would be very inefficient: How should data be stored? Operations are simpler & more specific: How do we take advantage of it? New programming languages for the above. (ACID) Reliability, security, consistency, currency π, σ, ρ, set ops, joins SQL

72 Database is just another model of information processing
(in disks) Then why study DB? Much more data, regular data techs would be very inefficient: How should data be stored? Operations are simpler & more specific: How do we take advantage of it? New programming languages for the above. (ACID) Reliability, security, consistency, currency π, σ, ρ, set ops, joins SQL

73 Two parts about database
purpose After the study Learn how to develop DB (database design) Be able to develop DB Help develop better DB necessary This course covers Understand how DB works (database principle) Know better about DB

74 Querying the Database The query compiler translates query into query plan (sequence of operations to be performed). Query compilation includes query optimization, to choose best sequence of operations Execution engine performs the operations, interacting with…

75 Storage and Buffer Management
Data usually is stored on disk, in units called blocks Storage manager controls movement of data between disk and main memory Buffer manager controls partitioning of main memory into block-sized regions Relies on info about data, schema, statistics, and indexes (special data structures for efficient access)

76 Transactions Usually database queries are grouped into transactions
A transaction must satisfy ACID properties: Atomicity: either all the changes or none of them are made to the database Consistency: transaction must preserve consistency constraints of the database Isolation: the result must be "as if" the transaction ran alone Durability: once transaction has completed, changes must not be lost

77 Transaction Processing
Every change is logged separately on disk by log manager After a system failure, recovery manager uses log on disk to reconstruct a consistent state Scheduler ensures that concurrently executing transactions do not interfere with each other

78 Outline of Course Representing things by tables E-R model (Ch. 4)
Good table structures Functional Dependencies (Ch. 3) Basic operations on relations Relational Algebra (Ch. 2) Storage management (Chs ) SQL languages in DDL/DML (Ch. 6) Query processing (Chs ) More on SQL (Chs. 7-9) Transition processing (Chs )

79 Outline of Course Representing things by tables E-R model (Ch. 4)
Good table structures Functional Dependencies (Ch. 3) Basic operations on relations Relational Algebra (Ch. 2) Storage management (Chs ) SQL languages in DDL/DML (Ch. 6) Query processing (Chs ) More on SQL (Chs. 7-9) Transition processing (Chs )

80 Outline of Course Representing things by tables E-R model (Ch. 4)
Good table structures Functional Dependencies (Ch. 3) Basic operations on relations Relational Algebra (Ch. 2) Storage management (Chs ) SQL languages in DDL/DML (Ch. 6) Query processing (Chs ) More on SQL (Chs. 7-9) Transition processing (Chs )

81 Outline of Course Representing things by tables E-R model (Ch. 4)
Good table structures Functional Dependencies (Ch. 3) Basic operations on relations Relational Algebra (Ch. 2) Storage management (Chs ) SQL languages in DDL/DML (Ch. 6) Query processing (Chs ) More on SQL (Chs. 7-9) Transition processing (Chs )

82 Outline of Course Representing things by tables E-R model (Ch. 4)
Good table structures Functional Dependencies (Ch. 3) Basic operations on relations Relational Algebra (Ch. 2) Storage management (Chs ) SQL languages in DDL/DML (Ch. 6) Query processing (Chs ) More on SQL (Chs. 7-9) Transition processing (Chs )

83 Outline of Course Representing things by tables E-R model (Ch. 4)
Good table structures Functional Dependencies (Ch. 3) Basic operations on relations Relational Algebra (Ch. 2) Storage management (Chs ) SQL languages in DDL/DML (Ch. 6) Query processing (Chs ) More on SQL (Chs. 7-9) Transition processing (Chs )

84 Outline of Course Representing things by tables E-R model (Ch. 4)
Good table structures Functional Dependencies (Ch. 3) Basic operations on relations Relational Algebra (Ch. 2) Storage management (Chs ) SQL languages in DDL/DML (Ch. 6) Query processing (Chs ) More on SQL (Chs. 7-9) Transition processing (Chs )

85 Outline of Course Representing things by tables E-R model (Ch. 4)
Good table structures Functional Dependencies (Ch. 3) Basic operations on relations Relational Algebra (Ch. 2) Storage management (Chs ) SQL languages in DDL/DML (Ch. 6) Query processing (Chs ) More on SQL (Chs. 7-9) Transition processing (Chs )

86 Outline of Course Representing things by tables E-R model (Ch. 4)
Good table structures Functional Dependencies (Ch. 3) Basic operations on relations Relational Algebra (Ch. 2) Storage management (Chs ) SQL languages in DDL/DML (Ch. 6) Query processing (Chs ) More on SQL (Chs. 7-9) Transition processing (Chs )


Download ppt "CPSC-310 Database Systems"

Similar presentations


Ads by Google