๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Back-end/MongoDB

Big Data Storage

๋ฐ˜์‘ํ˜•

์ด ๊ธ€์€ ์ „๊ณต "๋น…๋ฐ์ดํ„ฐ์‹œ์Šคํ…œ" ๊ฐ•์˜ ๋‚ด์šฉ์„ ์ •๋ฆฌํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค.

Centralized Storage

  • Data is stored on the database of one single machine
  • Relational databases
    • Allows related data to be stored across multiple tables, and linked by establishing a relationship between the tables ⇒ ๋‹ค์ˆ˜์˜ ํ…Œ์ด๋ธ”์— ์—ฐ๊ด€๋œ data๋ฅผ ์ €์žฅํ•˜๊ณ , ํ…Œ์ด๋ธ”๋“ค๊ฐ„์˜ ๊ด€๊ณ„๋ฅผ ์„ค์ •ํ•˜์—ฌ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค.
    • Inflexible - ์ฃผ๋กœ structured data์— ์ ํ•ฉํ•˜๊ณ  ๋‹ค๋ฅธ ํƒ€์ž…์— ๋Œ€ํ•ด ์œ ์—ฐ์„ฑ์ด ์—†๋‹ค.
    • Velocity - ๋น ๋ฅด๊ฒŒ ์ฆ๊ฐ€ํ•˜๋Š” ๋ฐ์ดํ„ฐ๋ณด๋‹จ ์ •์ ์ธ ๋ฐ์ดํ„ฐ๋ฅผ ์œ„ํ•ด ์„ค๊ณ„๋˜์–ด์žˆ๋‹ค.
    • No scalability - ํฐ ํฌ๊ธฐ๋กœ ํ™•์žฅํ•˜๊ธฐ ์‰ฝ์ง€ ์•Š๋‹ค.
    • Weak SQL - SQL ๊ธฐ๋ณธ ์ฟผ๋ฆฌ๋กœ๋Š” ํŠน์ • ์ฟผ๋ฆฌ๋ฅผ ๊ตฌํ˜„ํ•˜๊ธฐ ์–ด๋ ต๋‹ค.

Decentralized storage

  • Database run on multiple machines at the same time
  • NoSQL databases

What is NoSQL?

  • Some claim for it to mean “No SQL” ⇒ ์ผ๋ถ€์—์„œ๋Š” “No SQL”์„ ์˜๋ฏธํ•œ๋‹ค๊ณ  ํ•œ๋‹ค.
    • SQL์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ๋‹ค๋ฅธ ๋Œ€์ฒด ์ฟผ๋ฆฌ ์–ธ์–ด๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.
  • The definition is sometimes expanded to mean “Not only SQL” ⇒ ๋•Œ๋•Œ๋กœ “Not Only SQL”์œผ๋กœ ํ™•์žฅ๋˜๊ธฐ๋„ ํ•œ๋‹ค.
    • ์‹œ์Šคํ…œ์—์„œ SQL์„ ๋‹ค๋ฅธ ๊ธฐ์ˆ /์ฟผ๋ฆฌ ์–ธ์–ด์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•œ๋‹ค๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•œ๋‹ค.
  • Many argue that the one thing all NoSQL databases have in common is that they’re non-relational ⇒ ๋Œ€๋‹ค์ˆ˜๋Š” ๋ชจ๋“  NoSQL ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ํ•œ ๊ฐ€์ง€ ๊ณตํ†ต์ ์€ ๋น„๊ด€๊ณ„์ ์ด๋ผ๋Š” ๊ฒƒ์ด๋ผ๊ณ  ํ•œ๋‹ค.
    • “NoREL” is a more suitable name

Why NoSQL

  • Features of NoSQL
    • Flexible - ์Šคํ‚ค๋งˆ๊ฐ€ ์—†๊ฑฐ๋‚˜ ์—ฌ์œ  ์Šคํ‚ค๋งˆ๋ฅผ ๊ฐ€์ง„๋‹ค(๋ฐ์ดํ„ฐ ์Šคํ‚ค๋งˆ์˜ ์ •์˜๋ฅผ ์š”๊ตฌํ•˜์ง€ ์•Š๋Š”๋‹ค.)
    • Scalability - Scale-Up(vertical scaling)์„ ์‚ฌ์šฉํ•˜๋Š” RDBMS์™€ ๋‹ฌ๋ฆฌ, Scale-Out(horizotal scaling)์„ ์‚ฌ์šฉํ•œ๋‹ค.
    • Fault tolerance - single machin๋ณด๋‹ค several machine์ด ๋” fault tolerance๊ฐ€ ๋†’๋‹ค.
    • Open Source - ๋Œ€๋ถ€๋ถ„ NoSQL database๋Š” oepn source์ด๋‹ค.

NoSQL Databases

Representative NoSQL Databases

  • Key-Value Store
  • Column
  • Document
  • Graph

Key-Value Store Database

  • ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•˜๊ธฐ ์œ„ํ•ด์„œ ๊ฐ„๋‹จํ•œ key-value ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•œ๋‹ค.
  • ๋ฐ์ดํ„ฐ ์ €์žฅ ๋ฐฉ๋ฒ•์ด ๊ฐ„๋‹จํ•˜๋‹ค(Simple method of storing data)
  • ํ™•์žฅ์ด ์ž˜๋œ๋‹ค.(Scale Well)
  • key-value pair๋Š” ๋งŽ์€ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์—์„œ ์ ˆ ์ •๋ฆฝ๋œ ๊ฐœ๋…์ด๋‹ค
    • ex) Dictionary, hash, associative array, etc

Example of Key-Value Stores

  • Stock Trading

What can a key-value store database be used for?

  • ์›น์‚ฌ์ดํŠธ์—์„œ User profiles and session info
  • ๊ธฐ์‚ฌ/๋ธ”๋กœ๊ทธ ๋Œ“๊ธ€
  • ์ „ํ™”๋ฒˆํ˜ธ๋ถ€
  • IP forwarding tables
  • etc...

Key-Value DBMS

  • Redis
  • Oracle NoSQL Database
  • Project Voldemort
  • Aerospike
  • Oracle Berkeley DB

Document Store Database

  • ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•  ๋•Œ document-oriented model์„ ์‚ฌ์šฉํ•œ๋‹ค.
  • key-value store database์™€ ์œ ์‚ฌํ•˜์ง€๋งŒ, Document store database๋Š” semi-structure data๋กœ ๊ตฌ์„ฑ๋œ ๊ฐ’์„ ์‚ฌ์šฉํ•œ๋‹ค.
  • ํ•˜๋‚˜์˜ document์•ˆ์— ์—ฐ๊ด€๋œ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•œ๋‹ค.
  • ๊ฐ๊ฐ์˜ document๋Š” ๋‹ค์–‘ํ•œ ์ฟผ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” semi-structured ๋ฐ์ดํ„ฐ๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ๋‹ค.
    • Usually XML or JSON

What can a Document Database be used for?

  • Web application
  • ์œ ์ €๊ฐ€ ๋งŒ๋“œ๋Š” Content(Chat sessions, tweets, blog posts)
  • Networking/computing(Sensor data, log files)
  • Catalog Data

Examples of Document Store DBMS

  • MongoDB
  • DocumentDB
  • CouchDB
  • MarkLogic
  • OriendDB

Column Store Database

  • column oriented model์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•œ๋‹ค.
  • column family๋Š” ์—ฌ๋Ÿฌ๊ฐœ์˜ row๋“ค๋กœ ๊ตฌ์„ฑ๋œ๋‹ค.
  • ๊ฐ row๋Š” ๋‹ค๋ฅธ row์™€ ๋‹ค๋ฅธ ์ˆ˜์˜ colums์œผ๋กœ ๊ตฌ์„ฑ๋  ์ˆ˜ ์žˆ๋‹ค.
    • ๋‹ค๋ฅธ column ์ด๋ฆ„, ๋ฐ์ดํ„ฐ ์œ ํ˜• ๋“ฑ์„ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋‹ค.

 

 

  • Row Key : ๊ฐ row๋Š” ์‹๋ณ„ํ•˜ ์ˆ˜ ์žˆ๋Š” unique key๋ฅผ ๊ฐ€์ง„๋‹ค.
  • Column: ๊ฐ column์€ ์ด๋ฆ„, ๊ฐ’, timestamp๋ฅผ ๊ฐ€์ง„๋‹ค.

Examples of column store databases include

  • Bigtable
  • Cassandra
  • HBase
  • Vertica
  • Druid

Graph Database

  • ๋ฐ์ดํ„ฐ๋ฅผ ํ‘œํ˜„ํ•˜๊ณ  ์ €์žฅํ•˜๊ธฐ ์œ„ํ•ด graphical model์„ ์‚ฌ์šฉํ•œ๋‹ค.
  • relational model์˜ ๋Œ€์•ˆ์ด๋‹ค.
    • relational database์—์„œ, ๋ฐ์ดํ„ฐ๋Š” ๋ฏธ๋ฆฌ ์ •์˜๋œ ์Šคํ‚ค๋งˆ๊ฐ€ ์žˆ๋Š” ๊ฒฌ๊ณ ํ•œ ๊ตฌ์กฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ…Œ์ด๋ธ”์— ์ €์žฅ๋œ๋‹ค.
    • graph database์—์„œ๋Š”, ๋ฏธ๋ฆฌ ์ •์˜๋œ ์Šคํ‚ค๋งˆ๊ฐ€ ์—†๋‹ค.(๋‹จ์ˆœํ•˜๊ฒŒ ์ž…๋ จ๋œ ๋ฐ์ดํ„ฐ์˜ reflection์ด๋‹ค.)
  • ์—ฐ๊ฒฐ๋œ ๋ฐ์ดํ„ฐ๋กœ ์ž‘์—…ํ•˜๋Š”๋ฐ ๋งค์šฐ ์ ํ•ฉํ•˜๋‹ค.

  • circle์€ node์ด๊ณ , ๋ฐ์ดํ„ฐ๋ฅผ ํฌํ•จํ•œ๋‹ค.
  • ํ™”์‚ดํ‘œ๋Š” node ์‚ฌ์ด ๊ด€๊ณ„๋ฅผ ํ‘œํ˜„ํ•œ๋‹ค.

Example of Graph Databases

  • Neo4j
  • Blazegraph
  • GraphBase
๋ฐ˜์‘ํ˜•