[DB #00] Why Databases ?

이석환·2023년 10월 8일
0

Database

목록 보기
1/12
post-thumbnail

Why Use a Database ?

Prevalence of Databases (DBs)

Behind every sucessful website, there is a powerful database.
EX: UPS/FedEX's websites, Amazon, Google ...

1. Data Management Example

Scenario

  • Movie rental startup을 운영중이다.
  • 고객들이 영화 DVD 사본을 대여한다.
  • 각 영화는 여러 사본이 존재한다.

Needs

  • 연체된 DVD가 존재하는가 ?
  • 어떤 DVD를 고객이 대여해갔는가 ?

Solution : A "File-based" System

  • Advantages
    • Text editors는 사용이 쉽다.
    • record에 insert와 delete가 쉽다.

Complication : Queires ? (1/9)

Does not address needs : 사용자의 요구를 충족시키지 못하는 내용이나 쿼리가 있다

  • Query1: What movies has "Gildong Hong" rented ?
    • Execute: Search for "Gildong Hong"
      or
      Search for ^\s+Customer:\s*Gildong\s+Hong\s*,\s+Rented:

  • Query2: Are any disks overdue ?
    • Execute: HOW ?

Requirements
• Robust, sophisticated query language
• Clear separation between data organization (schema) and data
Data와 Data Organization(Schema) 사이의 정교한 query language가 필요하다.


Complication : Integrity (무결성) (2/9)

Lacks data integrity(무결성), Consistency(일관성)

  • Clerk misspells value/field
    Customer : Young Suk, Rented: Eraserhead, Deu : Sep. 3, 2022
  • Inputs improper value, same value differently
    Customer : Young Suh, Rented: The eraserhead, Deu : Sep. 3, 2022
  • Forgets/adds/reorders field
    Terms : weekly special, Due : Sep. 3, 2022, Rented : Eraserhead

Requirements
• Enforce constraints (제약조건) to permit only valid information to be input.
Input으로 오직 Valid한 정보만이 허락되는 제약조건이 필요하다


Complication : Update (3/9)

Add/delete/update fields in every record

  • Record Store location
    Customer: Young Suh, Rented : WWE, Due : Sep. 3, 2020, Store : Bukgu

  • Modify customer to first and last name
    First : Young, Last : Suh, Rented : WWE, Due : Sep. 3, 2020, Store : Bukgu

Add/delete/update new information collections

  • customer.txt file to record information
    Customer : Young Suh, Phone : 557-3344

Requirements
• Ability to manipulate the way data is organized.
Data 구성 방식을 조작할 수 있는 능력



Complication : Multiple Users (4/9)

• Two clerks edit rented.txt file at the same time.
1) 철수 starts to edit rented.txt, reads it into memory.
2) 영희 starts to edit rented.txt.
3) 철수 adds a record.
4) 철수 saves rented.txt to disk.
5) 영희 saves rented.txt to disk.

What’s wrong with this scenario?
메모리가 충돌되어 원하는 결과를 얻을 수 없다.

비행기 좌석를 예매하는 상황에서, 한 자리에 여러 사용자가 예매를 하고자 한다면 충돌이 발생하고 이러한 상황을 통제할 수 있어야 한다.

Requirements
• Must support multiple readers and writers.
• Updates to data must (appear to) occur in serial order.
다중 사용자 Readers & Writers에 대한 Support가 이루어져야함
Data의 업데이트는 serial order에서 발생해야 함 -> 데이터의 업데이트가 일련의 순서대로 수행되는 것처럼 보이거나 처리되어야 한다.

Complication : Crashes (5/9)

Crash during update may lead to inconsistent state.
• 철수 makes 250 of 500 edits to change ‘Jane Doe’ to her preferred name ‘Jan Doe’.
• Before 철수 saves it, Windows/Linux crashes!

Requirements
• Must update on all-or-none basis (a.k.a, atomicity).
• Implemented by commit or rollback if necessary.
트랜잭션은 성공적으로 완료되거나 아무런 영향도 미치치 않는 두 가지 상태 중 하나여야 한다.
필요하다면 commit 또는 rollback이 구현되어야 한다.

Complication : Data Physically Separate (6/9)

물리적으로 떨어져있는 데이터
Need

  • want to inform Avengers' fnas about the 'Avengers : End Game' movie.

Method

  • customer.txt contains address of customers.
    customer.txt는 customers의 address를 저장
  • Must merge with rented.txt to create mailing list.
    mailing list 생성을 위해 rented.txt와 merge 필요

Problems

  • Text editors incapable of such a merge (have to write a program)
    Text editors는 위와 같은 merge를 수행하지 못한다는 문제가 있다.
  • What if several 홍길동s?
    여러 명의 홍길동이 존재할 수 있다. (중복 데이터)
  • No information on some customers
    몇 명의 customer의 정보가 없을 수 있다.

Requirements
• Uniquely identify each customer.
• Make sure we have information on customers that rent the movie.
각각의 Customer를 Unique하게 식별할 수 있어야 한다.
영화를 빌려간 Customer들의 정보를 확실히 가지고 있어야 한다.



Complication : Security (7/9)

Customers want to know how many times a movie has been rented.

  • Provide access to rented.txt, but not to customer field, how I do that in an editor?

Customer가 해당 영화의 rent된 횟수를 알기를 원하는 상황
rented.txt에 대한 접근을 허용하면서 Customer 필드에 대한 접근은 허용하면 안 된다.
이를 Editor에서는 어떻게 처리 하나 ?

Clerks under 19 should not see history of R-rated rentals

  • Keep two lists of rentals?

19세 미만의 점원은 R-rated rentals에 대한 기록을 볼 수 없다.
rental list를 두 개를 두어야 하나 ?

Requirements
• Ability to control who has access to what information.
특정 Information에 누가 접근할 수 있는 지 Control할 수 있는 능력



Complication : Effciency (8/9)

Your customer list grows enormously.

  • rented.txt file gets huge (terabytes, petabytes, or more of data).
  • Slow to edit.
  • Slow to query for customer information.

Customer list는 엄청나게 증가한다.
-> rented.txt file은 여러 데이터로 계속해서 커질 것이다.
-> 편집하기에 느려진다.
-> 고객 정보에 대한 쿼리가 느려진다.

Requirements
• New data structures to improve query performance
• System automatically modifies queries to improve speed.
• Ability of system to scale to handle huge datasets
쿼리 성능 개선을 위한 새로운 자료 구조
시스템이 자동적으로 속도를 향상 시키기 위해 쿼리를 수정한다.
거대한 dataset을 핸들링할 수 있는 system의 능력



Complication : New Needs (9/9)

What pairs of movies are often rented together?

  • Calculate probability of movie combinations.

Do we need more copies of the Avengers movie anywhere?

  • Visualize rental history of Avengers by store area.

Requirements
• Collect and analyze summary data (요약 데이터).
• Use computer to mine for interesting trends and predict future trends (흥미로운 트렌드를 캐거나 예측)
• Support access to data by sophisticated programs.



Limitations of File-based Systems

Program must implement
• Security (보안)
• Concurrency control (동시성 제어)
• Support for schema reorganization (스키마 재구성)
• Data structures for performance improvement (성능 향상을 위한 데이터 구조): e.g. indexes (색인)

Observation
• Many applications need these services with high performance.

Solution
• Build and sell a software system to provide services, which is what?!

Reference
Database System Concepts | Abraham Silberschatz
데이터베이스 시스템 7th edition

profile
반갑습니다.

0개의 댓글

관련 채용 정보