NoSQL Guide & Sample

  • Published on
    17-Jun-2015

  • View
    562

  • Download
    5

Embed Size (px)

DESCRIPTION

NoSQL MongoDB install and sample

Transcript

<ul><li> 1. NoSQL Guide &amp; Sample S.O.Lab / OracleOn(Lee Sang On)14 1 8 </li></ul> <p> 2. NO SQL &amp; Not Only SQL Oracle , MSSQL , MySQL , DB , H , DB : DB : , 14 1 8 3. NoSQL ? ? NoSQL 3 NoSQL , NoSQL &amp; NoSQL , DB 14 1 8 4. NoSQL ? ? RDBMS . RDBMS DB SQL 90% RDBMS (?) : - - . ID: solab username: on Date: 2014-01-06 OrderNum: 201400123 item list 1. 20140111 / S / black / 2 / 3000$ 2. 20140112 / m / black / 1 / 7000$ 3. 20140113 / L / black / 3 / 5000$ Pay Method Card: Amex C.Number : 1234-123-1234 expiry: 04/201414 1 8 5. NoSQL ? ? RDBMS . RDBMS DB SQL 90% RDBMS (?) : - - . ID: solab username: on Date: 2014-01-06 OrderNum: 201400123 item list 1. 20140111 / S / black / 2 / 3000$ 2. 20140112 / m / black / 1 / 7000$ 3. 20140113 / L / black / 3 / 5000$ Pay Method Card: Amex C.Number : 1234-123-1234 expiry: 04/201414 1 8 Order_Info 6. NoSQL ? ? RDBMS . RDBMS DB SQL 90% RDBMS (?) : - - . ID: solab username: on Date: 2014-01-06 OrderNum: 201400123 item list 1. 20140111 / S / black / 2 / 3000$ 2. 20140112 / m / black / 1 / 7000$ 3. 20140113 / L / black / 3 / 5000$ Pay Method Card: Amex C.Number : 1234-123-1234 expiry: 04/201414 1 8 Order_Info User_Info 7. NoSQL ? ? RDBMS . RDBMS DB SQL 90% RDBMS (?) : - - . ID: solab username: on Date: 2014-01-06 OrderNum: 201400123 item list 1. 20140111 / S / black / 2 / 3000$ 2. 20140112 / m / black / 1 / 7000$ 3. 20140113 / L / black / 3 / 5000$ Pay Method Card: Amex C.Number : 1234-123-1234 expiry: 04/201414 1 8 Order_Info User_Info Order_Detail_Info 8. NoSQL ? ? RDBMS . RDBMS DB SQL 90% RDBMS (?) : - - . ID: solab username: on Date: 2014-01-06 OrderNum: 201400123 item list 1. 20140111 / S / black / 2 / 3000$ 2. 20140112 / m / black / 1 / 7000$ 3. 20140113 / L / black / 3 / 5000$ Pay Method Card: Amex C.Number : 1234-123-1234 expiry: 04/201414 1 8 Order_Info User_Info Order_Detail_Info credit_info 9. NoSQL ? ? RDBMS . RDBMS DB SQL 90% RDBMS (?) : - - . ID: solab username: on Date: 2014-01-06 OrderNum: 201400123 item list 1. 20140111 / S / black / 2 / 3000$ 2. 20140112 / m / black / 1 / 7000$ 3. 20140113 / L / black / 3 / 5000$ Pay Method Card: Amex C.Number : 1234-123-1234 expiry: 04/201414 1 8 Order_Info User_Info Order_Detail_Info credit_info 10. NoSQL ? ? RDBMS . RDBMS DB SQL 90% RDBMS (?) : - - . ID: solab username: on Date: 2014-01-06 OrderNum: 201400123 item list 1. 20140111 / S / black / 2 / 3000$ 2. 20140112 / m / black / 1 / 7000$ 3. 20140113 / L / black / 3 / 5000$ Pay Method Card: Amex C.Number : 1234-123-1234 expiry: 04/201414 1 8 Order_Info User_Info Order_Detail_Info credit_info 11. NoSQL ? ? RDBMS . RDBMS DB SQL 90% RDBMS (?) : - - . ID: solab username: on Date: 2014-01-06 OrderNum: 201400123 item list 1. 20140111 / S / black / 2 / 3000$ 2. 20140112 / m / black / 1 / 7000$ 3. 20140113 / L / black / 3 / 5000$ Pay Method Card: Amex C.Number : 1234-123-1234 expiry: 04/201414 1 8 Order_Info User_Info Order_Detail_Info credit_info 12. NoSQL ? ? RDBMS . RDBMS DB SQL 90% RDBMS (?) : - - . ID: solab username: on Date: 2014-01-06 OrderNum: 201400123 item list 1. 20140111 / S / black / 2 / 3000$ 2. 20140112 / m / black / 1 / 7000$ 3. 20140113 / L / black / 3 / 5000$ Pay Method Card: Amex C.Number : 1234-123-1234 expiry: 04/201414 1 8 Order_Info User_Info Order_Detail_Info credit_info 13. SNS, Smart Device , , : 14 1 8 14. SNS, Smart Device , , : : 14 1 8 15. SNS, Smart Device , , : : - - 14 1 8 16. SNS, Smart Device , , : : - - 14 1 8 17. SNS, Smart Device , , : : - - - . - Oracle Grid, MSSQL2008 . - , .14 1 8 18. SNS, Smart Device , , : : - - - . - Oracle Grid, MSSQL2008 . - , .RDBMS . .14 1 8 19. NoSQL : 1990 RDBMS(Strozzi NoSQL) SQL . NOSQL , , , No 14 1 8 20. NoSQL : 1990 RDBMS(Strozzi NoSQL) SQL . NOSQL , , , No NoSQL 714 1 8 21. NoSQL : 1990 RDBMS(Strozzi NoSQL) SQL . NOSQL , , , No NoSQL 7 -, , , H,,DB,DB14 1 8 22. NoSQL 3 - (Key- value) - - . - - . - . - , DB - , DB 14 1 8 23. DataBase , ,, , , 14 1 8 24. DataBase , ,, , , 14 1 8 25. DataBase , ,, , , 14 1 8 26. DataBase , ,, , , / / { id:1, name:Martin billingAddress:[{city:Chicago}] }14 1 8 27. DataBase , ,, , , / / { id:1, name:Martin billingAddress:[{city:Chicago}] } / / { id:99, customerId:1, orderItems:[{ productId:27, price:32.45, productName:NoSQL Distilled }], shippingAddress:[{city:Chicago}], orderPayment:[{ ccinfo:10000-10000-10000-10000, txnId:abcdefg123fg, billingAddress:{city:Chicago} }], }14 1 8 28. DataBase . / / { id:1, name:Martin billingAddress:[{city:Chicago}] } / / { id:99, customerId:1, orderItems:[{ productId:27, price:32.45, productName:NoSQL Distilled }], shippingAddress:[{city:Chicago}], orderPayment:[{ ccinfo:10000-10000-10000-10000, txnId:abcdefg123fg, billingAddress:{city:Chicago} }], }14 1 8 29. DataBase . / / { customer: { id:1, name:Martin, billingAddress:[{city:Chicago}], / / orders:[{ { id:99, id:99, customerId:1, customerId:1, orderItems:[{ orderItems:[{ productId:27, productId:27, price:32.45, price:32.45, productName:NoSQL Distilled productName:NoSQL Distilled }], }], shippingAddress:[{city:Chicago}], shippingAddress:[{city:Chicago}], orderPayment:[{ orderPayment:[{ ccinfo:1000-1000-1000-1000, ccinfo:10000-10000-10000-10000, txnId:adfncer123df, txnId:abcdefg123fg, billingAddress:{city:Chicago} billingAddress:{city:Chicago} }], }], }] } } } / / { id:1, name:Martin billingAddress:[{city:Chicago}] }14 1 8 30. NoSQL , ..... - + - 2 DataBase DATA UPDATE DataBase . RDB .(RDBMS SQL) .(NoSQL) .(-)14 1 8 31. NoSQL &amp; (replication) (sharding) - : - : - . , Master-slave, peer-to-peerA,BCA,B,C 14 1 8 D,E,F 32. (sharding) ? (server connection count reduce) NoSQL . (com.google.*****) A~D , E~G .... NoSQL DATABASE - . , DB ....14 1 8 33. Master-Slave() DATAA,B,C,D masterA,B,C,D slave -14 1 8 A,B,C,D slave . . 34. Peer-To-Peer() DATAA,B,C,D DATAmasterDATA A,B,C,DA,B,C,Dmastermaster- . - . - 14 1 8 35. Sharding + Master-SlaveA,BB,DmastermasterD-master&amp; B-slaveA,DC,BB,Dslave14 1 8 Cslaveslave 36. Sharding + Peer-To_PeerA,B14 1 8 CD,B -A,CA,DC,B PTP 3 , 2 37. NoSQL - 2 (051-123-1234/0511231234) - (write-write conict) - ( ) - ( ) - ( :SVN,GIT) - 1 : ( ) - 2 : , 14 1 8 38. - 14 1 8 39. - .14 1 8 40. - . / / { customer: { id:1, name:Martin, billingAddress:[{city:Chicago}], orders:[{ id:99, customerId:1, orderItems:[{ productId:27, price:32.45, productName:NoSQL Distilled }], shippingAddress:[{city:Chicago}], orderPayment:[{ ccinfo:1000-1000-1000-1000, txnId:adfncer123df, billingAddress:{city:Chicago} }], }] } }14 1 8 41. - . / / { customer: { id:1, name:Martin, billingAddress:[{city:Chicago}], orders:[{ id:99, customerId:1, orderItems:[{ productId:27, price:32.45, productName:NoSQL Distilled }], shippingAddress:[{city:Chicago}], orderPayment:[{ ccinfo:1000-1000-1000-1000, txnId:adfncer123df, billingAddress:{city:Chicago} }], }] } }12 A . .....14 1 8 42. - ID:1001 customer:Ann Items : {,8,2000,16000}, {,4,3000,12000}, {,2,5000,10000}, ........ :~~~ : ~~~14 1 8 43. - NoSQL ID:1001 customer:Ann Items : {,8,2000,16000}, {,4,3000,12000}, {,2,5000,10000}, ........ :~~~ : ~~~14 1 8 44. - NoSQL ID:1001 customer:Ann Items : {,8,2000,16000}, {,4,3000,12000}, {,2,5000,10000}, ........ :~~~ : ~~~14 1 8 map 45. - NoSQL ID:1001 customer:Ann Items : {,8,2000,16000}, {,4,3000,12000}, {,2,5000,10000}, ........ :~~~ : ~~~14 1 8 map 46. - NoSQL ID:1001 customer:Ann Items : {,8,2000,16000}, {,4,3000,12000}, {,2,5000,10000}, ........ :~~~ : ~~~14 1 8 :{price:16000,quantity:8}map 47. - NoSQL ID:1001 customer:Ann Items : {,8,2000,16000}, {,4,3000,12000}, {,2,5000,10000}, ........ :~~~ : ~~~14 1 8 :{price:16000,quantity:8} :{price:12000,quantity:4}map 48. - NoSQL ID:1001 customer:Ann Items : {,8,2000,16000}, {,4,3000,12000}, {,2,5000,10000}, ........ :~~~ : ~~~14 1 8 :{price:16000,quantity:8} :{price:12000,quantity:4}map:{price:10000,quantity:2} 49. - NoSQL ID:1001 customer:Ann Items : {,8,2000,16000}, {,4,3000,12000}, {,2,5000,10000}, ........ :~~~ : ~~~: price:16000,quantity:8 price:14000,quantity:7 price:20000,quantity:1014 1 8 :{price:16000,quantity:8} :{price:12000,quantity:4}map:{price:10000,quantity:2} 50. - NoSQL ID:1001 customer:Ann Items : {,8,2000,16000}, {,4,3000,12000}, {,2,5000,10000}, ........ :~~~ : ~~~: price:16000,quantity:8 price:14000,quantity:7 price:20000,quantity:1014 1 8 :{price:16000,quantity:8} :{price:12000,quantity:4}map:{price:10000,quantity:2} 51. - NoSQL ID:1001 customer:Ann Items : {,8,2000,16000}, {,4,3000,12000}, {,2,5000,10000}, ........ :~~~ : ~~~:{price:16000,quantity:8} :{price:12000,quantity:4}map: price:16000,quantity:8 price:14000,quantity:7 price:20000,quantity:1014 1 8 reduce:{price:10000,quantity:2} 52. - NoSQL ID:1001 customer:Ann Items : {,8,2000,16000}, {,4,3000,12000}, {,2,5000,10000}, ........ :~~~ : ~~~:{price:16000,quantity:8} :{price:12000,quantity:4}map:{price:10000,quantity:2}:: {price:50000,quantity:25}price:16000,quantity:8 price:14000,quantity:7 price:20000,quantity:1014 1 8 reduce 53. - : - : . - . - , . - . - .14 1 8 54. DB NoSQL ,, SQL . - . ( ) . Stored .{foo:3} {foo:3} {Foo:3}14 1 8 55. DB install 1. Homebrew (PackageManager) - xcode . - .ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"14 1 8 56. DB install 2. MongoDB - .brew install mongodb14 1 8 57. DB install 3. MongoDB - .mongod- .mongo14 1 8 58. DB install 4. MongoDB - .http://localhost:28017/14 1 8 59. MongoDB - mongod - mongo 14 1 8 60. MongoDB - mongod - mongo &gt; x= 200 &gt; x/514 1 8 61. MongoDB - mongod - mongo &gt; x= 200 &gt; x/514 1 8 &gt; Math.sin(Math.PI/2) &gt; new Date(2014/1/8) 62. MongoDB - mongod - mongo &gt; x= 200 &gt; x/5&gt; Math.sin(Math.PI/2) &gt; new Date(2014/1/8)&gt; SmADev in Seoul.replace(Seoul,Pusan)14 1 8 63. MongoDB - mongod - mongo &gt; x= 200 &gt; x/5&gt; Math.sin(Math.PI/2) &gt; new Date(2014/1/8)&gt; SmADev in Seoul.replace(Seoul,Pusan)14 1 8 64. MongoDB test DB - mongod - mongo &gt; use foobar &gt; db1. - insert . - (post) .14 1 8 65. MongoDB test DB - mongod - mongo &gt; use foobar &gt; db1. - insert . - (post) . &gt; post ={title:My Study Post, content:abcdefghijklnm, date:new Date()}14 1 8 66. MongoDB test DB - mongod - mongo &gt; use foobar &gt; db1. - insert . - (post) . &gt; post ={title:My Study Post, content:abcdefghijklnm, date:new Date()}&gt; db.blog.insert(post)14 1 8 67. 2. &gt; db.blog.nd()&gt; db.blog.ndOne()14 1 8 68. 3. - post .&gt; post.readcount =0 &gt; db.blog.update({title:"My Study Post"},post) &gt; db.blog.ndOne()14 1 8 69. 3. - post .&gt; post.readcount =0 &gt; db.blog.update({title:"My Study Post"},post) &gt; db.blog.ndOne()14 1 8 70. 4. &gt; db.blog.remove({title : "My Study Post"}) &gt; db.blog.nd() &gt; db.blog.ndOne()14 1 8 71. NoSQL DataBase 14 1 8 </p>