CSE 510 Web Data Engineering Database Design UB CSE 510 Web Data - - PowerPoint PPT Presentation

cse 510 web data engineering
SMART_READER_LITE
LIVE PREVIEW

CSE 510 Web Data Engineering Database Design UB CSE 510 Web Data - - PowerPoint PPT Presentation

CSE 510 Web Data Engineering Database Design UB CSE 510 Web Data Engineering How to Design a Database and Avoid Bad Decisions With experience Learn in CSE462 normalization rules of database design Think entities and


slide-1
SLIDE 1

CSE 510 Web Data Engineering

Database Design

UB CSE 510 Web Data Engineering

slide-2
SLIDE 2

UB CSE 510 Web Data Engineering 2

How to Design a Database and Avoid Bad Decisions

  • With experience…
  • Learn in CSE462 normalization rules of database

design

  • Think entities and relationships – translate to

relations

slide-3
SLIDE 3

UB CSE 510 Web Data Engineering 3

E/R-Based Design

Attribute

Enrollment Credits Students UBID FirstName LastName Number DateCode StartTime Classes Name EndTime

Entity Relationship

slide-4
SLIDE 4

UB CSE 510 Web Data Engineering 4

E/R  Relational Schema: Basic Translation

  • For every entity, create corresponding

table

– Include an ID attribute even if not in E/R

  • For every relationship, create table

– For each referenced entity Ei include foreign key attribute referencing ID of Ei

slide-5
SLIDE 5

UB CSE 510 Web Data Engineering 5

Movies Title Year Length StarsIn Owns Stars Name Address Studios Name Address

Example

slide-6
SLIDE 6

UB CSE 510 Web Data Engineering 6

3-Way Relationship

  • A studio has contracted with a particular star to

act in a particular movie

Movies Title Year Length Stars Name Address Studios Name Address Fee Contract

slide-7
SLIDE 7

UB CSE 510 Web Data Engineering 7

Relationships with Roles

Movies Title Year Length SequelOf

Original Sequel

slide-8
SLIDE 8

UB CSE 510 Web Data Engineering 8

“Subclassing”

Movies Title Year Length StarsIn Voices Stars Name Address Cartoons … IsA

slide-9
SLIDE 9

UB CSE 510 Web Data Engineering 9

Transaction Management

  • Transaction: Collection of actions that

maintain the consistency of the database if ran to completion & isolated

  • Goal: Guarantee integrity and

consistency of data despite

– Concurrency – Failures

  • Concurrency Control
  • Recovery
slide-10
SLIDE 10

UB CSE 510 Web Data Engineering 10

Concurrency & Failure Problems

  • Consider the “John & Mary”

checking & savings account

– C: checking account balance – S: savings account balance

  • Check-to-Savings transfer

transaction moves $X from C to S

– If it runs in the system alone and to completion, the total sum of C and S stays the same C2S(X=100) Read(C) C:=C-100 Write(C) Read(S) S:=S+100 Write(S)

slide-11
SLIDE 11

UB CSE 510 Web Data Engineering 11

Failure Problem & Recovery Module’s Goal

  • Database is in inconsistent

state after machine restarts

  • It is not the developer’s

problem to account for crashes

  • Recovery module guarantees

that all or none of a transaction happens and its effects become “durable” C2S(X=100) Read(C) C:=C-100 Write(C) CPU Halts Read(S) S:=S+100 Write(S)

slide-12
SLIDE 12

UB CSE 510 Web Data Engineering 12

Concurrency Problem & Concurrency Control Module’s Goals

  • If multiple

transactions run in sequence, the resulting database is consistent

  • Serial schedules

– De facto correct

Serial Schedule Read(C) C:=C+100 Write(C) Read(S) S:=S-100 Write(S) Read(C) C:=C+50 Write(C) Read(S) S:=S-50 Write(S)

slide-13
SLIDE 13

UB CSE 510 Web Data Engineering 13

Concurrency Problem & Concurrency Control Module’s Goals

  • Databases allow

transactions to run in parallel Good Schedule with Concurrency Read(C) C:=C+100 Write(C) Read(C) C:=C+50 Write(C) Read(S) S:=S-100 Write(S) Read(S) S:=S-50 Write(S)

slide-14
SLIDE 14

UB CSE 510 Web Data Engineering 14

Concurrency Problem & Concurrency Control Module’s Goals

  • “Bad” interleaved

schedules may leave database in inconsistent state

  • Developer should not

have to account for parallelism

  • Concurrency control

module guarantees serializability

– only schedules equivalent to serial ones happen

Bad Schedule with Concurrency Read(C) C:=C+100 Read(C) Write(C) C:=C+50 Write(C) Read(S) S:=S-50 Write(S) Read(S) S:=S-100 Write(S)