首页 \ 问答 \ 何时使用MongoDB或其他面向文档的数据库系统?(When to use MongoDB or other document oriented database systems? [closed])

何时使用MongoDB或其他面向文档的数据库系统?(When to use MongoDB or other document oriented database systems? [closed])

我们提供视频和音频剪辑,照片和矢量草图的平台。 我们从MySQL开始作为数据库后端,最近还包括MongoDB存储文件的所有元信息,因为MongoDB更符合要求。 例如:照片可能有Exif信息,视频也可能有我们要存储元信息的音轨。 视频和矢量图形不共享任何常见的元信息等,所以我知道,MongoDB是完美的存储这个非结构化数据并保持可搜索。

然而,我们继续开发我们的平台并添加功能。 现在,下一步将为我们的用户提供一个论坛。 现在出现的问题是:使用MySQL数据库,这将是存储论坛和论坛帖子等的一个不错的选择,也可以使用MongoDB?

所以问题是:何时使用MongoDB和何时使用RDBMS。 你会采取什么,mongoDB或MySQL,如果你有选择,你为什么要这样做?


We offer a platform for video- and audio-clips, photos and vector-grafics. We started with MySQL as the database backend and recently included MongoDB for storing all meta-information of the files, because MongoDB better fits the requirements. For example: photos may have Exif information, videos may have audio-tracks where we to want to store the meta-information of, too. Videos and vector-graphics don't share any common meta-information, etc. so I know, that MongoDB is perfect to store this unstructured data and keep it searchable.

However, we continue developing our platform and adding features. Now one of the next steps will be providing a forum for our users. The question that now arises is: use the MySQL database, which would be a good choice for storing forums and forum-posts, etc. or use MongoDB for this, too?

So the question is: when to use MongoDB and when to use a RDBMS. What would you take, mongoDB or MySQL, if you had the choice and why would you take it?


原文:https://stackoverflow.com/questions/1476295
更新时间:2024-01-21 10:01

最满意答案

通过更多的上下文,代码更有意义。

// used to store pointers to allocated memory
unsigned char *n[NO_OF_POINTERS]; 

int s[5000]; // used to store sizes when testing

....

for(i=0;i<NO_OF_ITERATIONS;i++) {
   k=myrand()%NO_OF_POINTERS; // pick a pointer
   if(n[k]) { // if it was allocated then free it
      // check that the stuff we wrote has not changed
      if(n[k][0]!=(unsigned char)(n[k]+s[k]+k))
         printf("Error when checking first byte!\n");
      if(s[k]>1 && n[k][s[k]-1]!=(unsigned char)(n[k]-s[k]-k))
         printf("Error when checking last byte!\n");
      FREE(n[k]);
   }
   size=randomsize(); // pick a random size
             size=1;
   n[k]=(unsigned char *)MALLOC(size); // do the allocation
   s[k]=size; // remember the size
   n[k][0]=(unsigned char)(n[k]+s[k]+k);  // put some data in the first and
   if(size>1) n[k][size-1]=(unsigned char)(n[k]-s[k]-k); // last byte
}

最后两行使用基于指针值( n[k] ),分配大小( s[k] )和指针索引( k )的公式将第一个和最后一个字节设置为值。 这个公式没有意义,它只是计算要存储的值,对于不同的指针分配将是不同的。

您突出显示的if语句检查在释放内存之前,第一个( n[k][0] )和last( n[k][s[k]-1] )字节的值没有改变。 该代码基本上是VirtualAllocVirtualFree函数的测试工具。


The code makes more sense with a bit more context.

// used to store pointers to allocated memory
unsigned char *n[NO_OF_POINTERS]; 

int s[5000]; // used to store sizes when testing

....

for(i=0;i<NO_OF_ITERATIONS;i++) {
   k=myrand()%NO_OF_POINTERS; // pick a pointer
   if(n[k]) { // if it was allocated then free it
      // check that the stuff we wrote has not changed
      if(n[k][0]!=(unsigned char)(n[k]+s[k]+k))
         printf("Error when checking first byte!\n");
      if(s[k]>1 && n[k][s[k]-1]!=(unsigned char)(n[k]-s[k]-k))
         printf("Error when checking last byte!\n");
      FREE(n[k]);
   }
   size=randomsize(); // pick a random size
             size=1;
   n[k]=(unsigned char *)MALLOC(size); // do the allocation
   s[k]=size; // remember the size
   n[k][0]=(unsigned char)(n[k]+s[k]+k);  // put some data in the first and
   if(size>1) n[k][size-1]=(unsigned char)(n[k]-s[k]-k); // last byte
}

The last two lines set the first and the last byte to values using a formula based on the pointer value (n[k]), the size of the allocation (s[k]), and the pointer index (k). There is no meaning to this formula, it's just a calculation of a value to be stored that will be different for different pointer allocations.

The if statements you highlighted check that the values of the first (n[k][0]) and last (n[k][s[k]-1]) bytes haven't changed before freeing the memory. The code is basically a test harness for the VirtualAlloc and VirtualFree functions.

相关问答

更多
  • 通过更多的上下文,代码更有意义。 // used to store pointers to allocated memory unsigned char *n[NO_OF_POINTERS]; int s[5000]; // used to store sizes when testing .... for(i=0;i
  • 你可以在4个python的东西上谷歌(或者只读官方的python文档) - 例如文件,字符串,字典和列表,最后会有几行python代码来处理它。 因为这看起来像是学习一些python的任务...... 如果您真的想学习,请为您考虑最佳解决方案 - 只需拆分任务并按步骤执行,例如,您需要: 从文件中读取数据 解析行(拆分名称和分数) 将它存储在某个地方,例如在名称为键的python字典中,以及作为值的python列表。 例如: scores['Bob'] == [8, 8, 7]看起来容易理解和简单。 关于将 ...
  • 我的问题是,我如何解释这一点? 这是否意味着我的数据是正态分布的,但是具有非零平均值(即不是标准正态分布),还是这个概率仅反映了其他情况? 你是对的。 如果运行normplot并获取非常接近拟合线的数据,则意味着您的数据具有非常接近正态分布的累积分布函数 。 0.5 CDF点对应于拟合正态分布的平均值。 (你的情况看起来约为0.002) 你得到一条直线的原因是y轴是非线性的,并且它被做成“弯曲”的方式,使得完美的高斯累积分布将映射成一条线:y轴标记与倒数成线性关系错误功能 。 当你看到两端时,它们的斜率比拟 ...
  • 在ruby hash和xml之间进行转换的savon是一个名为gyoku的gem。 对于gyoku,数组值导致多个元素(其名称由键给出)。 如果你不想这样,那么Addresses键的值必须是一个哈希,即你的输入应该是这样的 {"Addresses" => { "CurrentAddress" => { "Country" => "United Kingdom", ... }, "Previous" => { "Country" => "Uni ...
  • 它这样做: 将x的值分配给matrix ; matrix = x表达式的结果是分配的值(所有赋值表达式都是如此)。 我们称这个值为“x值”。 我不想从这里开始调用它,因为x只评估一次。 如果x值是truthy 1 ( 强制为true),它将matrix.length给n ; 否则,将x值赋给n 。 例如,如果x是[] ,则代码将matrix设置为指向同一个空数组x ,并将n设置为0 ( matrix.length后的matrix.length )。 其他示例(我在编辑问题之前编写了这些示例) :如果x是"f ...
  • 你的解释是大致正确的。 你的问题也是我问的问题。 我会说这取决于这个代码的目的; 有可能这是为了可读性而以这种方式写的; 如果你用英语说这个代码的目的,或许你就是这样描述它的。 我会警告说,这是非常糟糕的形式,但特别是这一部分: data sample; set sample; where ... ; 通常当你做不可逆转的事情时,最好不要写入你正在阅读的数据集(因为你正在丢失数据)。 WHERE不仅适用上述转换; 它实际上会过滤进入的行,因此只有符合WHERE条件的行才会在输出数据集中结束。 Yo ...
  • 零件从左到右进行评估。 -perm表示要查找具有给定权限集的文件。 -2是权限, writable by others 。 的! 否定了它之后的片段的真值,它是带参数l -type 。 -type l将匹配符号链接的文件,所以用! 此子句将匹配非符号链接的文件。 结合这两个子句,我们正在寻找可由“其他”编写的文件,而不是符号链接。 然后我们对这些文件执行-ls ,并将stderr从所有内容中删除。 The parts are evaluated left to right. The -perm says t ...
  • 向量c(TRUE, FALSE, FALSE)循环到整个向量,并将提取向量的第1,第4,第7等值。 它类似于将逻辑向量复制到向量的长度。 yVec[rep(c(TRUE, FALSE, FALSE), length.out = length(yVec))] 只要逻辑向量为TRUE,它将在'yVec'中提取相应的元素。 The vector c(TRUE, FALSE, FALSE) is recycling to the entire vector and will extract the 1st, 4t ...
  • 逐行,这里是变化: function IntNoise(32-bit integer: x) 我们不需要声明参数类型,也不想使用CamelCase,所以第一行是: def intnoise(x): 下一行唯一的问题是分号。 删除它,我们得到: x = (x << 13) ^ x x将向左移位 13位,然后结果将与x的起始值按位异或运算。 在下一行,再次没有分号, 7ffffff需要以0x为前缀,因此: return ( 1.0 - ( (x * (x * x * 15731 + 789221) + 13 ...
  • MSDN SqlDataReader.Read方法声明Read方法 - 将SqlDataReader推进到下一条记录。 并返回 如果有更多行,则为true; 否则是假的。 创建SqlDataReader对象时,它不指向第一个记录。 您需要调用Read方法。 如果调用成功,则SqlDataReader对象将指向第一个记录并返回True。 MSDN SqlDataReader.Read Method states that Read method - Advances the SqlDataReader to ...

相关文章

更多

最新问答

更多
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)
  • 是否可以嵌套hazelcast IMaps?(Is it possible to nest hazelcast IMaps? And whick side effects can I expect? Is it a good Idea anyway?)
  • UIViewAnimationOptionRepeat在两个动画之间暂停(UIViewAnimationOptionRepeat pausing in between two animations)
  • 在x-kendo-template中使用Razor查询(Using Razor query within x-kendo-template)
  • 在BeautifulSoup中替换文本而不转义(Replace text without escaping in BeautifulSoup)
  • 如何在存根或模拟不存在的方法时配置Rspec以引发错误?(How can I configure Rspec to raise error when stubbing or mocking non-existing methods?)
  • asp用javascript(asp with javascript)
  • “%()s”在sql查询中的含义是什么?(What does “%()s” means in sql query?)
  • 如何为其编辑的内容提供自定义UITableViewCell上下文?(How to give a custom UITableViewCell context of what it is editing?)
  • c ++十进制到二进制,然后使用操作,然后回到十进制(c++ Decimal to binary, then use operation, then back to decimal)
  • 以编程方式创建视频?(Create videos programmatically?)
  • 无法在BeautifulSoup中正确解析数据(Unable to parse data correctly in BeautifulSoup)
  • webform和mvc的区别 知乎
  • 如何使用wadl2java生成REST服务模板,其中POST / PUT方法具有参数?(How do you generate REST service template with wadl2java where POST/PUT methods have parameters?)
  • 我无法理解我的travis构建有什么问题(I am having trouble understanding what is wrong with my travis build)
  • iOS9 Scope Bar出现在Search Bar后面或旁边(iOS9 Scope Bar appears either behind or beside Search Bar)
  • 为什么开机慢上面还显示;Inetrnet,Explorer
  • 有关调用远程WCF服务的超时问题(Timeout Question about Invoking a Remote WCF Service)