2. Developing Web App
❖ I wanted to build a Web App
❖ Renewal of Management Tool
❖ High performance is unnecessary
❖ Present: MySQL Schema
❖ Too many relations
❖ Fuckin’!!!
3. SELECT u.name, c.name, a.code ...
FROM users u
LEFT JOIN map USING(user_id)
LEFT JOIN classes c USING(class_id)
LEFT JOIN addresses a USING(user_id)
WHERE c.categ = ?
AND u.age >= ? AND ...
5. Features of MongoDB
“Schema-less”
❖ MongoDB stores “documents” as BSON(binary JSON)
❖ without CREATE TABLE or ALTER TABLE
❖ TABLE => collection, RECORD => document
❖ Powerful Query
❖ next...
7. Features of MongoDB
“Schema-less”
❖ Point: “Denormalize” as much as you can
❖ not using relation or mapping table
❖ embedding to the document’s column
❖ ...Why?
8. Features of MongoDB
“no JOIN”
❖ MongoDB doesn’t support JOIN !
❖ If you want to JOIN multi collections, you should do it
on application side
❖ find document => lookup reference => find document
❖ some drivers support DBRef, but it is just format...
❖ hoge: { $ref:"coll", $id:"id" }
❖ So, intentional embedding relational documents is better
9. Features of MongoDB
“no Transaction”
❖ MongoDB doesn’t support transaction !
❖ MongoDB is designed for updating “one” document
❖ some Atomic operations($inc, findAndModify)
❖ It is difficult to update multi documents Atomically
❖ MongoDB update likes MySQL AUTOCOMMIT
’s
10. Features of MongoDB
“no Transaction”
❖ If you want to update multi documents ACID-ly...
❖ !!! You should compromise some aspects !!!
❖ Optimistic/Pessimistic Lock
❖ Two Phase Commit
❖ MVCC if possible...
12. I ♡ RDBMS
❖ RDBMS have great transaction function
❖ Safe for many trouble scenes
❖ But RDBMS have some weak points
❖ which are hot spots of NoSQL!
❖ So, I should learn about Database more and more
❖ I bought “Database Management Systems”
❖ Let’s read it with me!