跳至主要内容

MongoDB学习笔记

这是我阅读《MongoDB权威指南》的学习笔记,前七章侧重在开发者角度谈MongoDB,后面才是运维管理者角度

一. 理论部分

入门


  • 文档:多个键及其关联的值有序地放置在一起便是文档
  • 集合:一组文档

虽然子集合没有特别的地方,但还是很有用,很多MongoDB工具中都包含子集合

  • GridFS是一种存储大文件的协议,使用子集合来存储文件的元数据,这样就与内容块分开了
  • MongoDB的Web控制台通过子集合的方式将数据组织在DBTOP部分
  • 绝大多数驱动程序都提供语法糖,为访问指定集合的子集合提供方便。例如:在数据库shell里面,db.blog代表blog集合,db.blog.posts代表blog.posts集合
在MongoDB中使用子集合来组织数据是很好的方法,在此强烈推荐

数据类型


  • JSON表现力也有限制,因为只有null,布尔,数字,字符串,数组和对象几种类型,
  • MongoDB保留JSON键值对基础上,增添了其他一些数据类型


使用GridFS存储文件有如下原因:

  • 会直接利用业已建立的复制或分片机制,所以对于文件存储来说故障恢复和扩展都很容易
  • 可以避免用户上传内容的文件系统出现的某些问题
  • 不产生磁盘碎片,因为MongoDB分配数据文件空间以2GB为一块



开发者角度到此为止,下一篇是运维角度的学习

Popular posts from 产品随想的博客

产品随想 | 陪读《乔布斯传》:1-17章

乔布斯经典照片集 坐在麗莎電腦旁。他說:「毕加索曾說:「好的藝術家懂得模仿,佛大的藝術家善於偷取。」因此,窃取偉大的點子沒有什麼好羞耻的。 與蓋茲在電話中達成協議:「比爾,謝謝你支持蘋果。因為你的支持,世界將變得更美好。」 1997年蘋果在波士頓舉行的麥金塔世界大會,蓋茲透過衛星連線在巨大的螢幕上出現。質伯斯說:「我真是笨死了,竟然讓蓋兹以這種方式現身。他讓我看起來好沙小。」 ──时刻自省 前言 The people who are crazy enough to think they can change the world are the ones who do. 只有那些瘋狂到以為自己可以改變世界的人, 才能改變這個世界。 這麼些年來,賈伯斯說起話來的認真與專注態度,著實打動不少人。我們一直保持連絡,即使在他被逐出蘋果之後,我們還有來往。每次他有新產品要推出時,像 NeXT 電腦或皮克斯 (Pixar)的電影,他就會來找我。他常帶我去曼哈頓下城一家壽司店用餐,講起他的產品,渾身散發出光和熱,眉飛色舞的說這是他登峰造極之作。我喜歡這個人。 ──对自己产品深深的爱 他的堅持教我疑惑。人人都知道賈伯斯不道餘力捍衛隱私, 而且我不知道他是否看過我寫的任何一本傳記。我還是不敢立刻答應,只說或許再等等。然而到了 2009年,我接到他太太蘿琳. 鮑威爾打來的電話。她直截了當說:「如果你還想為史帝夫寫傳,最好趕快動筆。」這是他第二次因病向公司請長假。我坦言他早在2004 年得知自己罹患胰臟癌的時候就曾主動邀我寫傳,但我當時對他罹癌的事一無所知。蘿琳解釋說,他們盡量保密,因此當時根本沒幾個人知道。他是在動手術的前夕打電話給我的。 ──和Make Something Wonderful对照起来看 他還說,自從他回到蘋果重新掌權,這十二年來是他創造新產品的高峰期,但他還有更重要的目標,也就是效法惠普的惠立和普克(David Packard),締造一家創新動力無限的公司,進而超越惠普。 ──苹果公司才是乔布斯最得意的产品 他說:「我一直認為,自己是個偏向人文的孩子,但我也喜歡電子的東西。後來,我讀到寶麗來(Polaroid)創辦人蘭德 (Edwin Land)曾說過,一個人能站在人文和科學的交會口,兼容贯通,才是真正的人才。在那當下,我决定要當這樣的人。」他似乎在暗示我,這可以做為傳...

Steve Jobs at 44, By Michael Krantz, 1999

Differences and Similarities Between Apple and Pixar Apple turns out many products--a dozen a year; if you count all the minor ones, probably a hundred. Pixar is striving to turn out one a year. But the converse of that is that Pixar's products will still be used fifty years from now, whereas I don't think you'll be using any product Apple brings to market this year fifty years from now. Pixar is making art for the ages. Kids will be watching Toy Story in the future. And Apple is much more of a constant race to continually improve things and stay ahead of the competition.  His Role At Pixar At Pixar my job is to help build the studio and recruit people and help create a situation where they can do the best work of their lives. And to some degree it's the same at Apple. But at Pixar, I don't direct the movies, whereas at Apple probably, if I had to pick a role out of a film production, I'd be the director. So it...

产品随想 | 周刊 第85期:e-Residency与数字游民

  David Shambaugh   https://www.google.com/search?q=David+Shambaugh 中国问题研究专家,著作极多 郭玉闪   https://zh.wikipedia.org/wiki/郭玉闪?useskin=vector 中国公共知识分子 我只想好好观影   github.com/BetterWorld-Liuser/autoMovies 刘煜辉:中国资本市场灵魂出窍 最有活力的公司几乎不在A股   https://finance.sina.com.cn/stock/marketresearch/2017-06-23/doc-ifyhmtek7705574.shtml 回看17年的专家讲话,还是挺有水平的,挺多都认可 纽约文化沙龙   https://www.youtube.com/@user-cu2hl5tf6y/videos 视频质量出奇的高,推荐 透视中国政治by吴国光、程晓农 备忘下,貌似评价挺好的一本书 CAPI China Chair Wu Guoguang (吴国光 / 吳國光)   https://www.youtube.com/playlist?list=PLIt1szHhnm_Hso3jGUbfGpnEAbsPOuEVV 因为热爱中国,我们越要看懂中国 AI Canon   https://a16z.com/2023/05/25/ai-canon/ in this post, we’re sharing a curated list of resources we’ve relied on to get smarter about modern AI. We call it the “AI Canon” because these papers, blog posts, courses, and guides have had an outsized impact on the field over the past several years. 希望中国的投資機構,也能有更多的分享與輸出,提升整個社會的認知 Cantonese Font 粵語字體   https://visual-fonts.com/zh/...

巴菲特致股东信-1975年

 笔记: 华盛顿邮报已成为伯克希尔第一重仓股 翻译: 雪球:https://xueqiu.com/6217262310/131409324 备份:https://archive.ph/4hgK3 原文: To the Stockholders of Berkshire Hathaway Inc.: Last year, when discussing the prospects for 1975, we stated “the outlook for 1975 is not encouraging.” This forecast proved to be distressingly accurate. Our operating earnings for 1975 were $6,713,592, or $6.85 per share, producing a return on beginning shareholders ’ equity of 7.6%. This is the lowest return on equity experienced since 1967. Furthermore, as explained later in this letter, a large segment of these earnings resulted from Federal income tax refunds which will not be available to assist performance in 1976. On balance, however, current trends indicate a somewhat brighter 1976. Operations and prospects will be discussed in greater detail below, under specific industry titles. Our expectation is that significantly better results in textiles, earnings added from recent acquisitio...

Interview with Steve Jobs, WGBH, 1990

Interviewer: what is it about this machine? Why is this machine so interesting? Why has it been so influential? Jobs: Ah ahm, I'll give you my point of view on it. I remember reading a magazine article a long time ago ah when I was ah twelve years ago maybe, in I think it was Scientific American . I'm not sure. And the article ahm proposed to measure the efficiency of locomotion for ah lots of species on planet earth to see which species was the most efficient at getting from point A to point B. Ah and they measured the kilocalories that each one expended. So ah they ranked them all and I remember that ahm...ah the Condor, Condor was the most efficient at [CLEARS THROAT] getting from point A to point B. And humankind, the crown of creation came in with a rather unimpressive showing about a third of the way down...

Linux私房菜-14章 Linux帐号管理

1.认识三个文件夹 '/etc/passwd' '/etc/shadow' '/etc/group' 2.Mac更改Terminal shell: chsh -s /bin/bash 3.权限更改的一种姿势: chmod u+x file    user group others 4.一般帐号密码忘记:root身份passwd即可    root帐号密码忘记:重启进入用户维护模式再以 passwd命令更改密码,或Live CD开机挂载根目录再修改/etc/shadow,将root密码字段清空,重启后root将不再需要密码 5.有效用户组与初始用户组认识  groups命令查看当前登录用户支持的用户组

Steve Jobs: Rolling Stone’s 2003 Interview

  When Steve Jobs cruises into the airy reception area on the Apple Computer campus in Cupertino, California, on a recent morning, nobody pays much attention to him, even though he’s the company’s CEO. He’s wearing shorts, a black T-shirt and running shoes. Tall and a little gawky, Jobs has a fast, loping walk, like a wolf in a hurry. These days Jobs seems eager to distance himself from his barefoot youth – who was that crazy kid who once called the computer “a bicycle for the mind”? – and driven to prove himself as a clear-thinking Silicon Valley capitalist. Jobs punches the elevator button to the fourth floor, where his small office is located. For a man who is as responsible as anyone for the wonder and chaos of Silicon Valley, Jobs’ view of it all is surprisingly modest: shrubby treetops extending out toward San Francisco Bay, the distant whoosh of the freeway below. There is nothing modest, however, about Apple’s recent accomplishments. In the past few months,...

关于建筑实习的经验贴

慢慢整理实习的帖子,如果近期太阳能竞赛不占用太多时间的话,可以开始准备实习了 一.  给自己的问题   1. 你的设计风格是什么   2. 实习的目的 二. 事务所推荐   1. 墨臣,住宅(商业地产)做的很棒,项目管理做的比较好,但是相对来说公建项目比较少       如果希望接触多种类型项目的话考虑一下,多多了解这个事务所,赖军   2. 标准营造,张珂,重视方案设计的惊喜把控,重视图解,还有手工模型   3. 大舍,不浮夸,有自己的设计理念,效率高,唯一不加班公司 三. 学院派建筑师   1. 何镜堂事务所,缺点是周期长,待遇不高,风格单一,设计类型单一   2.  直向(新史家小学,方法上典型霍尔的风格,董功是霍尔弟子)       TAO迹(腾冲的那个博物馆不错)       山水秀(祝晓峰的风格很小清新,朱家角的房子)       业余       家琨(在符合本时代的建筑材料的运用上很有造诣,再生砖,鹿野苑....)       非常(张永和,作品说不出来有多好,但是又总觉得很精妙,二分宅) 四. 设计院   1. 商业建筑设计公司实习推荐  CCDI,DC,UA   2.  大连院,东北院,华东院,中建北京院   3. 不推荐同济院,因为挂靠的小公司很多,鱼龙混杂 五. 先锋派建筑师   1. UNStudio,项目比扎哈的脚踏实地而且思考深度高很多   2. BIG,设计的起源都是一个平淡朴实但是又很精妙的理由   3. 蓝天组   4. 国内事务所推荐  李虎(霍尔的合伙人)的open,侯梁(貌似的是玛雅,不知道用rhino和       GH),徐东昕,徐甜甜的DNA,徐卫国(感觉这老爷子在国内参数化设计界可以呼风唤       雨了)   5. 不推...

产品随想 | 周刊 第67期:静水铭室

Products Design Scenes #77   https://walling.app/TGE6qnCacxmwEV3d2lg2/design-scenes-77efbc88e4bbaeefbc89 非常不错的产品/设计周报 静水铭室   https://liuliu.me/ 静水可铭,丰山须镂。 - Silent Water and Curved Mountain 不错的中英博客 Classic HCI Demos   https://jackrusher.com/classic-ux/ A curated collection of HCI demo videos produced during the golden age from 1983-2002. 经典老演示Demo health-code-index   https://github.com/ilovexjp/health-code-index 健康码模拟 - 索引 EnergyStar   https://github.com/imbushuo/EnergyStar EnergyStar is a terrible* Windows application that leverages Windows EcoQoS API to throttle any inactive user process and background applications to improve system thermal and battery life, similar to the process management strategy on modern Apple macOS releases. 中共政治精英数据库   https://chinadatalab.ucsd.edu/elites/ Victor Shih/史宗瀚维护的一个履历库 Tribler   https://github.com/Tribler/tribler Privacy enhanced BitTorrent client with P2P content discovery 在美国执法区会有帮助 nuclear   https://github....

产品随想 | 周刊 第128期:将时间转化为知识和体验

自行车棚效应:我们为什么在小事上纠结,却对大事视而不见?   https://limboy.me/posts/bike-shedding Benz-Patent   https://www.mercedes-benz.com/en/innovation/milestones/benz-patent-motor-car/ 豐田博物館   https://toyota-automobile-museum.jp/tw/ 值得一去的汽车博物馆 一人公司   https://github.com/cyfyifanchen/one-person-company one-person-company, 一人公司 AI 工具系列 wujiaxian   https://wujiaxian.com/ 可能吧创始人的个人Blog,介绍自己的方式,很值得学习 日本京都10大設計熱點!「建築大師貝聿銘操刀美術館,皆川明設計旅館、選物店,還有全球最美的藍瓶咖啡店舖!」   https://www.elle.com/tw/life/style/g33846398/2020-kyoto-10-hotspots/ 京都真是非常美 Henry L. Stimson   https://en.wikipedia.org/wiki/Henry_L._Stimson?useskin=vector While Kyoto may have satisfied the military criteria for a useful target, Stimson objected, declaring in a meeting if the Interim Committee on June 1, 1945, "...there was one city that they must not bomb without my permission and that was Kyoto." 人性的努力保护了京都 Brooke Astor, 105, Aristocrat of the People, Dies   https://www.nytimes.com/2007/08/14/obituaries/14astor.html 值得尊敬...