“核心数据不是关系数据库”。为什么这很重要知道? [英] "Core Data is not a relational database." Why exactly is this important to know?

查看:109
本文介绍了“核心数据不是关系数据库”。为什么这很重要知道?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意识到这可能是很多人的常识,所以如果这看起来像一个愚蠢的问题,请道歉。

I realize this may be common sense for a lot of people, so apologies if this seems like a stupid question.

我试图学习iOS的核心数据编程,我已经反复阅读并听说它说Core Data(CD)不是关系数据库。但是关于这一点,还有很少有人说,或者为什么在学术意义之外知道重要的。我的意思是功能至少,似乎你可以使用CD,因为它是一个数据库的大多数东西 - 存储和获取数据,运行查询等。从我对它的初步理解,我不真的看到它是如何与数据库。

I am trying to learn core data for iOS programming, and I have repeatedly read and heard it said that Core Data (CD) is not a relational database. But very little else is said about this, or why exactly it is important to know beyond an academic sense. I mean functionally at least, it seems you can use CD as though it were a database for most things - storing and fetching data, runnings queries etc. From my very rudimentary understanding of it, I don't really see how it differs from a database.

我不怀疑这一区别是很重要的事实。我相信,很多聪明的人不会浪费他们的时间在这一点,如果它是没有用的理解。但我想要有人请解释 - 理想情况下与示例 - CD不是一个关系数据库如何影响我们如何使用它?或者,如果我没有被告知CD不是一个关系数据库,这将如何影响我作为一个Objective-C / Swift程序员的性能?

I am not questioning the fact that the distinction is important. I believe that a lot of smart people would not be wasting their time on this point if it weren't useful to understand. But I would like someone please to explain - ideally with examples - how CD not being a relational database affects how we use it? Or perhaps, if I were not told that CD isn't a relational database, how would this adversely impact my performance as an Objective-C/Swift programmer?

如果他们将CD作为关系数据库处理,可能会尝试做错误的事情?或者,有一些关系数据库不能做的事情,或者光盘设计不够好吗?

Are there things that one might try to do incorrectly if they treated CD as a relational database? Or, are there things which a relational database cannot do or does less well that CD is designed to do?

谢谢大家的集体智慧。

Thank you all for your collective wisdom.

推荐答案

人们强调不是关系数据库的角度,因为有一些数据库经验的人容易与Core Data结果来自于尝试直接应用他们的经验。一些示例:

People stress the "not a relational database" angle because people with some database experience are prone to specific errors with Core Data that result from trying to apply their experience too directly. Some examples:


  • 创建本质上是SQL联结表的实体。这几乎没有必要,通常使事情更复杂和容易出错。核心数据直接支持多对多关系。

  • 在实体中创建唯一的ID字段,因为他们认为他们需要一个ID字段来确保唯一性并创建关系。有时创建自定义唯一ID很有用,通常不是。

  • 根据这些唯一ID而不是使用Core Data关系来设置对象之间的关系,即保存相关对象的唯一ID使用ObjC / Swift语义来关联对象。

核心数据可以并且通常用作数据库,其他关系数据库的条款是一个很好的方法来拧紧它。

Core Data can and often does serve as a database, but thinking of it in terms of other relational databases is a good way to screw it up.

这篇关于“核心数据不是关系数据库”。为什么这很重要知道?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆