SQL Database와 NoSQL의 차이점은 아래의 table과 같지만 가장 중요한 점은 데이터 저장 방법이 table 형태인지, JSON type "Key-Value" 형태인지 여부이다.
Differences between SQL and NoSQL
The table below summarizes the main differences between SQL and NoSQL databases.
SQL DatabasesNoSQL Databases
Data Storage Model | Tables with fixed rows and columns | Document: JSON documents, Key-value: key-value pairs, Wide-column: tables with rows and dynamic columns, Graph: nodes and edges |
Development History | Developed in the 1970s with a focus on reducing data duplication | Developed in the late 2000s with a focus on scaling and allowing for rapid application change driven by agile and DevOps practices. |
Examples | Oracle, MySQL, Microsoft SQL Server, and PostgreSQL | Document: MongoDB and CouchDB, Key-value: Redis and DynamoDB, Wide-column: Cassandra and HBase, Graph: Neo4j and Amazon Neptune |
Primary Purpose | General purpose | Document: general purpose, Key-value: large amounts of data with simple lookup queries, Wide-column: large amounts of data with predictable query patterns, Graph: analyzing and traversing relationships between connected data |
Schemas | Rigid | Flexible |
Scaling | Vertical (scale-up with a larger server) | Horizontal (scale-out across commodity servers) |
Multi-Record ACID Transactions | Supported | Most do not support multi-record ACID transactions. However, some—like MongoDB—do. |
Joins | Typically required | Typically not required |
Data to Object Mapping | Requires ORM (object-relational mapping) | Many do not require ORMs. MongoDB documents map directly to data structures in most popular programming languages. |
Mongo start Commands
Start command | Termination command | |
Server | #mongod | Ctrl + c |
Shell | #mongo | Ctrol + c |
Mongo Shell CRUD Commands(생성, 조회, 업데이트, 삭제)
Shell Commands | Remark |
db.foods.insert({name: "Kimchi", "origin: "Korea", isFav: true}) | foods에 name과 origin, isFav이란 Key에 해당하는 value들을 각각 저장 |
db.foods.find() | foods에 저장된 모든 값들을 출력한다 |
db.foods.find({name: "sushi"}) | foods에 저장된 데이터 중 Key-Value가 각각 name, sushi인 데이터를 모두 보여준다. |
db.foods.update({name: "Kimch"}, {name: "Bulgogi"}) | name이 Kimch인 데이터를 {name: "Bulgogi"}라는 값으로 update한다. 기존의 3개 Key-Value가 사라지고, 오직 name: Bulgogi라는 1개의 Key-Value 값만 저장된다. |
db.foods.update({name: "Kimch"}, {$set: {name: "Bulgogi"}}) | name이 Kimch인 데이터에서 name만 Bugogi로 업데이트한다 |
db.foods.remove({name: "Bulgogi"}) | name이 "Bulgogi"인 데이터를 모두 삭제한다. |
'Full stack development > The Web Developer Bootcamp(2020)' 카테고리의 다른 글
305. Introduction to Mongoose Pt. 1 (0) | 2020.09.27 |
---|---|
302. Note about the installing MongoDB (0) | 2020.09.27 |
300. YelpCamp: Styling Nav and Forms (0) | 2020.09.26 |
299. YelpCamp: Styling Campgrounds (0) | 2020.09.26 |
298. Note about YelpCamp: Styling Campgrounds Lecture (0) | 2020.09.26 |