何时使用Core Data和何时使用Sqlite? [英] When to use Core Data and when to use Sqlite?

查看:141
本文介绍了何时使用Core Data和何时使用Sqlite?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习Core Data,以前我在我的一个项目中使用了SQLite。我的问题是,我应该使用什么方案Core Data vesus SQLite?我已经阅读了Core Data的一些优点,它提供了可视化方式设计数据结构,访问数据的抽象级别和SQLite可以在多平台上使用,但有什么与数据大小有关的?

解决方案

核心数据:


  1. 主要功能是图形管理(虽然读取和写入磁盘是一个重要的支持功能) / li>

  2. 操作存储在内存中的对象(虽然可以从磁盘中随意加载)


  3. <


  4. 非事务性,单线程,单用户(除非


  5. 只能在内存中操作


  6. 需要保存过程


  7. 可以在内存中快速创建数百万个新对象(虽然保存这些对象会很慢)

    / li>
  8. 将数据约束留给程序的业务逻辑方


数据库或SQLite:


  1. 主要功能是存储和提取数据


  2. 存储在磁盘上的数据(或最小和增量加载的数据)


  3. 可以是事务性,线程安全的多用户


  4. 永久保存到磁盘(通常会崩溃)


  5. 提供数据约束,例如唯一键

    ol>

    参考从下面的链接
    http://cocoawithlove.com/2010/02/differences-between-core-data-and.html


    I was learning Core Data and previously I have used SQLite in one of my projects. My question is, what scenario should I use Core Data vesus SQLite? I've read some of the advantages of Core Data, that it provides visual way to design data structure, abstract level of accessing data and SQLite can be use on multi platform but is there anything related to data size? That if data size is large than we should use Core Data or vice-versa?

    解决方案

    Core Data:

    1. Primary function is graph management (although reading and writing to disk is an important supporting feature)

    2. Operates on objects stored in memory (although they can be lazily loaded from disk)

    3. Works with fully-fledged objects that self-manage a lot of their behavior and can be subclassed and customized for further behaviors

    4. Non-transactional, single threaded, single user (unless you create an entire abstraction around Core Data which provides these things)

    5. Only operates in memory

    6. Requires a save process

    7. Can create millions of new objects in-memory very quickly (although saving these objects will be slow)

    8. Leaves data constraints to the business logic side of the program

    Database or SQLite:

    1. Primary function is storing and fetching data

    2. Operates on data stored on disk (or minimally and incrementally loaded)

    3. Stores "dumb" data

    4. Can be transactional, thread-safe, multi-user

    5. Can drop tables and edit data without loading into memory

    6. Perpetually saved to disk (and often crash resilient)

    7. Can be slow to create millions of new rows

    8. Offers data constraints like "unique" keys

    Referred from below link http://cocoawithlove.com/2010/02/differences-between-core-data-and.html

    这篇关于何时使用Core Data和何时使用Sqlite?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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