31
CS3200 – Database DesignSpring 2018Derbinsky Database Management Systems: An Architectural View Lecture 1 January 6, 2018 Database Management Systems: An Architectural View 1

Database Management Systems: An Architectural View

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Database Management Systems: An Architectural View

Lecture 1

January 6, 2018

Database Management Systems: An Architectural View

1

Page 2: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Outline1. What is a Database? A DBMS?2. Why use a DBMS?3. Databases in Context4. Design and Implementation Process

January 6, 2018

Database Management Systems: An Architectural View

2

Page 3: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

What is a Database?

January 6, 2018

Database Management Systems: An Architectural View

3

Page 4: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

What is a Database?

January 6, 2018

Database Management Systems: An Architectural View

4

Page 5: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

What is a Database?A collection of related data, most often…

– reflects some aspect of the real world– logically coherent with inherent meaning– designed, built, and populated with data for a

specific purpose• intended group of users• some preconceived applications with which these

users are interested• application requirements in terms of performance,

security, redundancy, concurrency, etc.

January 6, 2018

Database Management Systems: An Architectural View

5

Page 6: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Database Management SystemDBMS

A collection of programs that enables users to create and maintain a database

– Supports specifying the data types, structures, and constraints of the data

– Stores the data on some medium under control of the DBMS

– Supports querying and updating the database

– Protects data against malfunction and unauthorized access

January 6, 2018

Database Management Systems: An Architectural View

6

Page 7: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Why use a DBMS?

January 6, 2018

Database Management Systems: An Architectural View

7

Common tradeoff in CS:A. Code from scratch

• Pros: you know your problem best (so fast, customized)• Cons: slow, labor intensive, need to add/change features?

B. Find a library/tool that solves [part of] your problem• Pros: fast via bootstrapping, better designed?• Cons: understand the tool, may not be efficient, support?

DBMSs adopt some set of limiting assumptions in order to efficiently support a useful feature set over a wide class of possible databases

Page 8: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Example: Student Records• Given a school with MANY students (NEU: ~25k, UM: ~45k), each

with some data (name, ID, DOB, classes)

• Write a program that can efficiently…– Retrieve a random student– Retrieve the first/last student, according to…

• Last name• DOB

– Retrieve a student by…• ID• Name (with *’s)

– Retrieve a class roster (all students in class X)– Handles adding/removing/editing students/classes– Handles multiple simultaneous reads/writes– Provides differing access rights– Handles OS faults/power outages…

January 6, 2018

Database Management Systems: An Architectural View

8

Page 9: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Many Kinds of DBMSs (1)• Graph databases

– Create nodes, edges, labels– Query about relationships and paths

• Find your friends• Find someone that can help you learn databases

• Spatial databases– Objects in 2D/3D– Query locations, relations

• Collision detection

January 6, 2018

Database Management Systems: An Architectural View

9

Page 10: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Many Kinds of DBMSs (2)• Document stores

– Create dynamic documents– Query about contents

• Find by author, title, content, etc. patterns

• Key-Value stores– Associative array– Scalable, fault-tolerant– Query

January 6, 2018

Database Management Systems: An Architectural View

10

Page 11: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Relational DBMSWe focus on relational databases

Based on the relational data model– Researched ~45 years, widely used

• Free/paid implementations for personal use, embedded systems, small/large enterprise

January 6, 2018

Database Management Systems: An Architectural View

11

Page 12: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Relational Databases (1)Table or “Relation”

January 6, 2018

Database Management Systems: An Architectural View

12

Must be an integer > 0

Must be a number [0,4]Constraints

Name SSN Phone Address Age GPA

BenBayer 305-61-2435 555-1234 1FooLane 19 3.21

Chung-cha Kim 422-11-2320 555-9876 2BarCourt 25 3.53

BarbaraBenson 533-69-1238 555-6758 3Baz Blvd 19 3.25

STUDENT

Table Name Attributes/Columns

Rows/Tuples

Has to be unique

Page 13: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Relational Databases (2)More Tables!

January 6, 2018

Database Management Systems: An Architectural View

13

Name SSN Phone Address Age GPA

BenBayer 305-61-2435 555-1234 1FooLane 19 3.21

Chung-cha Kim 422-11-2320 555-9876 2BarCourt 25 3.53

BarbaraBenson 533-69-1238 555-6758 3Baz Blvd 19 3.25

STUDENT

SSN Dorm

305-61-2435 555Huntington

422-11-2320 Baker

533-69-1238 555Huntington

DORMSSN Class

305-61-2435 COMP355

422-11-2320 COMP355

533-69-1238 MATH650

305-61-2435 MATH650

422-11-2320 BIOL110

CLASS

Values in one table can be forced to come from

another(“Referential Integrity”)

Page 14: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Relational Databases (3)Queries!

January 6, 2018

Database Management Systems: An Architectural View

14

Name SSN Phone Address Age GPA

BenBayer 305-61-2435 555-1234 1FooLane 19 3.21

Chung-cha Kim 422-11-2320 555-9876 2BarCourt 25 3.53

BarbaraBenson 533-69-1238 555-6758 3Baz Blvd 19 3.25

STUDENT

What is the average GPA of students in MATH650?1. Find all SSN in table

Class where Class=MATH650

2. Find all GPA in table Student where SSN=#1

3. Average GPA in #2

Result

3.23

SSN Dorm

305-61-2435 555Huntington

422-11-2320 Baker

533-69-1238 555Huntington

DORMSSN Class

305-61-2435 COMP355

422-11-2320 COMP355

533-69-1238 MATH650

305-61-2435 MATH650

422-11-2320 BIOL110

CLASS

Page 15: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Relational Databases (3)Queries!

January 6, 2018

Database Management Systems: An Architectural View

15

Name SSN Phone Address Age GPA

BenBayer 305-61-2435 555-1234 1FooLane 19 3.21

Chung-cha Kim 422-11-2320 555-9876 2BarCourt 25 3.53

BarbaraBenson 533-69-1238 555-6758 3Baz Blvd 19 3.25

STUDENT

Result

3.23

SSN Dorm

305-61-2435 555Huntington

422-11-2320 Baker

533-69-1238 555Huntington

DORMSSN Class

305-61-2435 COMP355

422-11-2320 COMP355

533-69-1238 MATH650

305-61-2435 MATH650

422-11-2320 BIOL110

CLASS

SELECT AVG(STUDENT.GPA)FROM

STUDENT INNER JOIN CLASSON STUDENT.SSN=CLASS.SSN

WHERE CLASS.Class='MATH650';

Page 16: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Relational Databases (4)Users!

January 6, 2018

Database Management Systems: An Architectural View

16

DBMS ClientsApplication Server

Page 17: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

January 6, 2018

Database Management Systems: An Architectural View

17

Databases in ContextThree-Tier Architecture

Page 18: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Relational DBMS Features (1)• Data independence via data models

– Conceptual representation independent of underlying storage or operation implementation

January 6, 2018

Database Management Systems: An Architectural View

18

ER Diagrams

Relations

Page 19: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Relational DBMS Features (2)• Operation abstraction via…

– Declarative languages• Structured Query Language (SQL)

– Data… definition, manipulation, query

– Programmatic APIs• Function libraries (focus), embedded languages,

stored procedures, etc.

January 6, 2018

Database Management Systems: An Architectural View

19

Page 20: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Relational DBMS Features (3)• Reliable concurrent transactions

– (A)tomicity: “all or nothing”– (C)onsistency: valid -> valid’– (I)solation: parallel execution, serial result– (D)urability: once it is written, it is so

• High performance– Buffering, caching, locking (like a mini OS)– Query optimization, redundant data

structures (e.g. indexes, materialized views)

January 6, 2018

Database Management Systems: An Architectural View

20

Page 21: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Relational DBMS Features (4)• Authentication and authorization

– Discussed in context of other security concerns/techniques

• Backup and recovery– Logging, replication, migration

January 6, 2018

Database Management Systems: An Architectural View

21

Page 22: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Why NOT to use a DBMSYour application…• involves a single user• has simple/well-defined data/operations

– DBMS may be overkill

However, DBMS techniques may be useful– We will discuss useful and scalable indexing

structures and processes

January 6, 2018

Database Management Systems: An Architectural View

22

Page 23: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

1. Database designers2. System analysts & application

programmers3. Database administrators4. End users5. Back-end

a. DBMS designer/implementerb. Tool developersc. SysAdmins

January 6, 2018

Database Management Systems: An Architectural View

23

Databases in ContextPeople

Page 24: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Relational DBMS

January 6, 2018

Database Management Systems: An Architectural View

24

Page 25: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Database Design and Implementation Process

January 6, 2018

Database Management Systems: An Architectural View

25

Page 26: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Requirements Collection & Analysis • Data/Constraints

“The company is organized into departments. Each department has a unique name, number, and a particular employee who manages the department. We keep track…”

• Functional Needs– Operations/queries/reports

• Frequency– Performance, security, etc.

January 6, 2018

Database Management Systems: An Architectural View

26

Page 27: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Conceptual Design

• Software– UML– Form design

• Database– Transaction design– Report design

January 6, 2018

Database Management Systems: An Architectural View

27

Data Application

Page 28: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Logical Design

• Normalization

• Supporting code (that does not depend upon database)– Possibly using techniques

from databases (e.g. indexing)

January 6, 2018

Database Management Systems: An Architectural View

28

Data Application

Page 29: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Physical Design

• Index, materialized view selection and analysis

• Implementing operations as queries

• Implementing constraints as keys, triggers, views

• Implementing multi-user security as grants

January 6, 2018

Database Management Systems: An Architectural View

29

Data Application

Page 30: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Implementation and Tuning

• DDL statements• De-normalization,

updating indexes/materialized views

• Query integration• Profiling

queries/operations• Security, concurrency,

performance, etc. analysis

January 6, 2018

Database Management Systems: An Architectural View

30

Data Application

Page 31: Database Management Systems: An Architectural View

CS3200 – Database Design・ ・・ Spring 2018・ ・・Derbinsky

Summary• A database is a collection of related data that reflects

some aspect of the real world; is logically coherent with inherent meaning; and is designed, built, and populated with data for a specific purpose

• A database management system (DBMS) is a collection of programs that enables users to create and maintain a database

• There are many types – we will focus on relationaldatabases (RDBMS)

• The typical database design process is an iterative process of requirements collection/analysis, conceptual design, logical design, physical design, and system implementation/tuning

January 6, 2018

Database Management Systems: An Architectural View

31