Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1...

27
Introduction to Databases Lecture 1 Chapters 1 - 2 Robb T. Koether Hampden-Sydney College Wed, Jan 16, 2013 Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 1 / 23

Transcript of Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1...

Page 1: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Introduction to DatabasesLecture 1

Chapters 1 - 2

Robb T. Koether

Hampden-Sydney College

Wed, Jan 16, 2013

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 1 / 23

Page 2: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

1 Overview of the Course

2 Databases

3 Benefits of Databases

4 The Concurrency Problem

5 Assignment

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 2 / 23

Page 3: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Outline

1 Overview of the Course

2 Databases

3 Benefits of Databases

4 The Concurrency Problem

5 Assignment

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 3 / 23

Page 4: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Overview of the Course

Relational databasesBasicsNormal formsTriggersViews

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 4 / 23

Page 5: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Overview of the Course

Dynamic web pagesHTMLCSSPHPJavascriptAJAX

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 5 / 23

Page 6: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Overview of the Course

Semistructured databasesXMLXPathXQueryXSLT

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 6 / 23

Page 7: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Project

Develop a social network application for the web.

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 7 / 23

Page 8: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Outline

1 Overview of the Course

2 Databases

3 Benefits of Databases

4 The Concurrency Problem

5 Assignment

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 8 / 23

Page 9: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Databases

Definition (Database)A database (DB) is a collection of related data.

Definition (Database Management System)A database management system (DBMS) is a program that acceptsqueries into a database and returns responses.

Definition (Query)A query is a request that is sent to a DBMS instructing it to perform anoperation on a database. A query may retrieve, insert, delete, orupdate data in the database.

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 9 / 23

Page 10: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Databases

User DBMS DatabaseQuery

Optimizedquery

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 10 / 23

Page 11: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Databases

User DBMS DatabaseResponse Response

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 10 / 23

Page 12: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Databases

Characteristics of a DBMS.Limited redundancyRestricted access (privileges and views)Persistent storageEfficiencyBackup and recoveryMultiple users (concurrency)Data integrity

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 11 / 23

Page 13: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Databases

As we will see, it can be quite tedious to enter the queries througha command line.Often the “user” is actually an application program or a webpage,in which the queries are preprogrammed.After our initial study of databases, we will design webpages thatwill automatically query the underlying database.

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 12 / 23

Page 14: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Outline

1 Overview of the Course

2 Databases

3 Benefits of Databases

4 The Concurrency Problem

5 Assignment

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 13 / 23

Page 15: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Benefits of Databases

A few of the benefits of using a database:The user does not need to have knowledge of how the data isstored. He works through a user-friendly interface.Different users can be given different views of the data. Each usermay be unaware of the views that other users have.Data can be easily shared among users.

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 14 / 23

Page 16: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Benefits of Databases

OnlineCatalog

SalesRecords Inventory

Customer ManagerSalesman

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 15 / 23

Page 17: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Benefits of Databases

Customer ManagerSalesman

ComprehensiveDatabase

(Catalog, Sales,Inventory)

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 15 / 23

Page 18: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Various Roles

Roles of various individuals involved.The database administrator (DBA) – Oversees the entire system.The database designer – Designs a database to meet the specs.The user – Queries the database according to his needs.

At various times in this course, we will be the database designerand the database user.

One other person involved is the person who built the DBMS.

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 16 / 23

Page 19: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Various Roles

Roles of various individuals involved.The database administrator (DBA) – Oversees the entire system.The database designer – Designs a database to meet the specs.The user – Queries the database according to his needs.

At various times in this course, we will be the database designerand the database user.One other person involved is the person who built the DBMS.

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 16 / 23

Page 20: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Outline

1 Overview of the Course

2 Databases

3 Benefits of Databases

4 The Concurrency Problem

5 Assignment

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 17 / 23

Page 21: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Concurrency

Multiple users accessing the very same data at the very sametime leads to the concurrency problem.For example, Alice, a customer, requests the price of item #123.At the very same time, Bob, an employee, is updating the price ofitem #123.Which price will Alice see?

It depends on who goes first, Alice or Bob.

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 18 / 23

Page 22: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Concurrency

Multiple users accessing the very same data at the very sametime leads to the concurrency problem.For example, Alice, a customer, requests the price of item #123.At the very same time, Bob, an employee, is updating the price ofitem #123.Which price will Alice see?It depends on who goes first, Alice or Bob.

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 18 / 23

Page 23: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Concurrency

More significantly, Alice, an airline employee goes online to selecta list of passengers on flight #123.At the very same time, Bob, another airline employee, goes onlineto change the flight number from #123 to #456.Alice selects the first 50 names of passengers on flight #123.At that moment, the flight number is changed to #456.The last 50 names are not selected because the flight numberwas no longer #123.This type of conflict must be avoided.

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 19 / 23

Page 24: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

OLAP

Most database applications fall into one of two categories: OLAPor OLTP.

Definition (Database)Online analytical processing (OLAP) involves querying a database toobtain summary data, typical retrievals and aggregation.

A typical OLAP application would be to get the total daily salesfrom online purchases.OLAP is computationally intensive (e.g., summing over millions ofrecords).This is more like what we will do when we first study databases.

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 20 / 23

Page 25: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

OLTP

Definition (Database)Online transaction processing (OLTP) involves many small queries,typically insertions.

A typical OLTP application would be a database of onlinepurchases. Each purchase is inserted into the database.OLTP is not computationally intensive.This is more like what we will do with PHP and Javascript.

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 21 / 23

Page 26: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Outline

1 Overview of the Course

2 Databases

3 Benefits of Databases

4 The Concurrency Problem

5 Assignment

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 22 / 23

Page 27: Introduction to Databases - H-SCpeople.hsc.edu/faculty-staff/robbk/Coms480/Lectures...Read Chapter 1 - Databases and Database Users. Read Chapter 2 - Database System Concepts and Architecture.

Assignment

Read Chapter 1 - Databases and Database Users.Read Chapter 2 - Database System Concepts and Architecture.

Robb T. Koether (Hampden-Sydney College) Introduction to Databases Wed, Jan 16, 2013 23 / 23