MongoDB
来源:互联网 发布:轻薄笔记本 知乎 编辑:程序博客网 时间:2024/04/18 21:13
1. MongoDB
In MongoDB there are no server-side joins.
Generally, you will want one database collection for each of your top level objects.
You do not want a collection for every “class” – instead, embed objects.
Data within a Mongo collection tends to be contiguous on disk. Thus, table scans of the collection are possible, and efficient. Collections are very important for high throughput batch processing.
Each record is a document. A document, however, more closely represents an object as a whole.
2. Design a MongoDB model
When using mongodb, a general rule of thumb is that you use embeding and copying of data when it seems reasonable and fallback to referencing seperate entities when the user case demands it.
So one of the main decision to take when designing a MongoDB model, is what should be a top level document and what should be embedded in another document?
There is no server-side relations between documents, so each reference requires an additional trip from the client.
3. Lift: Mong-Record
Generally speaking each Lift Mong-Record entity you create represents a collection. By default, the collection will be a pluralized name of the class. Which means if you have a class “User”extend mongrecord[User] you will get a collection named users in MongoDB. You can specifiy the collection name in companion object by override collectionName method as below:
override def collectionName = “mypersons”
如何选择是否使用embed document?
对于写频繁的,最好单独存入collecton中,然后关联。
对于一次写入,基本不更新的,则使用embed document存储。
- Mongodb
- MongoDB
- mongodb
- mongodb
- mongodb
- MongoDB
- mongodb
- MongoDB
- MongoDb
- mongodb
- MongoDB
- mongodb
- mongodb
- MongoDB
- MongoDB
- mongoDB
- MongoDB
- MongoDB
- ThinkPHP的CURD方法及查询方法一览
- 京东买书后
- JAVA JDBC方式连接字符串的基本步骤
- resport .ent报表中当除数为零,文本框显示"错误号"。解决办法
- phpmyadmin设置密码和修改密码的方法
- MongoDB
- 基站定位(2)
- Using IntelliJ IDEA to develop Lift applications
- magento 常用插件 key 与 url 地址
- FreeBSD下MongoDB数据库的安装
- 我的第一个android小程序(wifi的开关button的实现)
- 同一个表中查询不同的数据,执行时间相差很远,是什么原因?
- 影响滤波器实现结构的三大因素
- 管理者的四个转变