introduction to database systems cs2300: file structures...

37
CS2300: File Structures and Introduction to Database Systems Lecture 3: Database System Concepts Chapters 1 & 2 Doug McGeehan 1

Upload: others

Post on 25-Jun-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

CS2300: File Structures and Introduction to Database Systems

Lecture 3: Database System ConceptsChapters 1 & 2

Doug McGeehan

1

Page 2: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Types of Databases and Database Applications

• Traditional Applications:– Numeric and Textual Databases

• More Recent Applications:– Multimedia Databases– Geographic Information Systems (GIS)– Data Warehouses– Real-time and Active Databases

2

Page 3: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

3

Page 4: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Basic Concepts• An Attribute:

– A single piece of data– Typically a String, Numeric, or Boolean value– Value could be unspecified (“null”)– Examples: first name, price

• An Entity (Row / Record):– A collection of fields defining a particular object– Example: a person, supermarket product

• A Table– A collection of records describing many objects

sharing a common schema– Example: classroom roster, supermarket inventory 4

Page 5: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Example of a Database Schema

55

Page 6: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

• A Database:– A collection of populated tables

– Tables typically relate to each other

• A Database Management System (DBMS):– A software system designed to store, manage, and

facilitate access to databases

• A Database System– The DBMS software together with the data itself– Sometimes the applications using a database

are also included6

Basic Concepts

Page 7: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

7

Simplified Database System Environment

Raw DataDatabase

system

DB

Internal representation

Application Server

Page 8: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Typical DBMS Functionality

• Define a particular database in terms of its data types, structures, and constraints

• Construct or Load the initial database contents on a secondary storage medium (i.e. hard drives)

• Manipulate the database:– Retrieval: Querying, generating reports– Modification: Insertions, deletions and updates to its content

• Processing and Sharing by multiple concurrent users and application programs – yet, keeping all data valid and consistent

8

Page 9: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Typical DBMS Functionality

• Other features:– Protection or security measures to prevent

unauthorized access– Presentation and visualization of data– Maintaining the database and associated

programs over the lifetime of the database application

9

Page 10: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Is a File System a DBMS?

10

Page 11: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Database Management Systems

• What more could we want from a file system?

– concurrency control– recovery– simple, efficient ad hoc queries– benefits of good data modeling– … …

11

Page 12: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

12

What is a Data Model?

• An abstract representation• Hides low level details• Describes DB structure

– Data types– Relationships– Constraints

• Categories of data models– Conceptual data model– Implementation data model– Physical data model

Page 13: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Conceptual Data Models

• High level: from the user’s perspective• Easy to understand for end user• For example: ER diagrams

– “Entity-Relationship”– Will cover in more detail next week

13

Page 14: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

An Example Database: JoeSS

• Entities:– STUDENT– COURSE– SECTION (of COURSE)– DEPARTMENT– INSTRUCTOR…

14

Conceptual Data Models

Page 15: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

JoeSS (continued):

• Relationships among entities:– SECTIONs cover a specific COURSE– STUDENTs attend a specific SECTION– COURSEs have prerequisite COURSE(s)– INSTRUCTOR teaches SECTION– COURSE is offered by DEPARTMENT– STUDENT majors in DEPARTMENT– ……

15

Conceptual Data Models

Page 16: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Implementation Data Models

• Also called representational data models• Easy to understand by end user• Can be implemented directly in a computer

– Data types– Data sizes– Relationship representation

• Example: Relational Model

16

Page 17: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

JoeSS (continued):

• Relationships among entities:– SECTIONs cover a specific COURSE– STUDENTs attend a specific SECTION– COURSEs have prerequisite COURSE(s)– INSTRUCTOR teaches SECTION– COURSE is offered by DEPARTMENT– STUDENT majors in DEPARTMENT– ……

17

Implementation Data Models

Page 18: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Physical Data Models

• Low level: For computer specialists/DBMS implementer

• Represents how data is actually storedon a computer– Record formats – Record orderings – Access paths (indexes, hashes, etc)

18

Page 19: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

DBMS Architecture

Let’s put data models together!

19

Page 20: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Three-Schema ArchitectureWhat is in each schema?• Internal schema: physical data model

– Physical storage structure– Data storage details, access paths

• Conceptual schema: conceptual or implementation data model– Structure of the entire database– Entities, data types, relationships, user operations,

constraints• External schemas: describe the various user views.

– Usually uses the same data model as the conceptual schema

– Could also provide derived views built on top of the conceptual schema 20

Page 21: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

21

Three-Schema Architecture

• Advantages of three-schema architecture– Self-describing nature

• Use of catalogs for schemas

– Achieve Data Independence• Support for multiple user views• Insulation of programs and data

Page 22: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Data Independence

• Ability to change one level schema without affecting other levels of schema– Three-schema architecture implements

the concept of data independence– Changes in one schema

• No need to change other schemas• Just modify the mappings between the two

– Logical Data Independence– Physical Data Independence

22

Page 23: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Data Independence

• Logical Data Independence– The capacity to change the conceptual schema

without having to change the external schemas and their associated application programs.

• Physical Data Independence– The capacity to change the internal schema

without having to change the conceptual schema.

23

Page 24: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Three-Schema Architecture

• Mapping between Database Schemas– Process of transforming requests between

different database levels (schemas)– Note: there is some overhead in compilation &

execution of queries– Time consuming

24

Page 25: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Database Schema

• The description of a database

• Includes relationships between entities.

• Schema Diagram:– An illustrative display of (most aspects of)

a database schema.

2525

Page 26: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Database Schema from earlier

2626

Page 27: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Database Instance

• The actual data stored in a database at a particular moment in time

• This includes the collection of all the data in the database

• Also called database state (or occurrence or snapshot)

2727

Page 28: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Database State

• Initial Database State– the database state when it is initially loaded into

the system.

• Valid State– A state that satisfies the structure and constraints

of the database.

2828

Page 29: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Example ofa DatabaseState:

2929

Page 30: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Schemas versus Instances

• Distinguish between the description of a database and database itself.

• Database schema: description of a database.

• Database instances: actual data stored in database.

3030

Page 31: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Database Schema vs. Database State

• Distinction– The database schema changes very

infrequently.

– The database state changes every time the database is updated.

3131

Page 32: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Database Systems

• Main Characteristics1. Self-describing nature2. Insulation between programs and data3. Data Abstraction4. Support of multiple views of the data5. Sharing of data and multi-user transaction

processing

32

Page 33: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Main Characteristics of Database Systems

1. Self-describing nature of a database system:– A DBMS catalog stores the description of a particular

database (e.g. data structures, types, and constraints)– This allows the DBMS software to work with different

database applications.

2. Insulation between programs and data:– Called program-data independence.– Allows changing data structures and storage organization

without having to change the DBMS access programs.

33

Page 34: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Main Characteristics of Database Systems

3. Data Abstraction: – A data model is used to hide storage details and present the

users with a conceptual view of the database.– Programs refer to the data model constructs rather than data

storage details

4. Support of multiple views of the data:– Each user may see a different view of the database, which

describes only the data of interest to that user.

34

Page 35: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

Main Characteristics of Database Systems

5. Sharing of data and multi-user transaction processing:– Allowing a set of concurrent users to retrieve from and to

update the database.– Concurrency control within the DBMS guarantees that each

transaction is correctly executed or aborted– Recovery subsystem ensures each completed transaction

has its effect permanently recorded in the database– OLTP (Online Transaction Processing) is a major part of

database applications. This allows hundreds of concurrent transactions to execute per second.

35

Page 36: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

DBMS Languages

• DDL (Data Definition Language)– Describe conceptual schema

• SDL (Storage Definition Language)– Specify internal schema

• VDL (View Definition Language)– Specify external view

• DML (Data Manipulation Language)– Manipulate the populated data

• Modern DB → All in one (e.g. SQL)36

Page 37: Introduction to Database Systems CS2300: File Structures andweb.mst.edu/~djmvfb/courses/cs2300/static/media/cs2300 - 03 - Dat… · 1. Self-describing nature of a database system:

What’s Next …

• Please email your group information to meby 11:59pm Sept 3

– Check the syllabus for my email address– Can also message me through Canvas

• Entity-Relationship (ER) Model (Chapter 3)

37