CoreData对象或用于复杂报表的SQL语句? [英] CoreData objects or SQL statements for complex reporting?

查看:105
本文介绍了CoreData对象或用于复杂报表的SQL语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iOS应用具有从PostgreSQL数据库继承的模型。该应用程序具有报告功能,将来可能会变得更加复杂。另外,可能需要将本地应用程序数据与PostgreSQL数据库服务器同步。

My iOS app has a model carried over from a PostgreSQL database. The application has reporting functionality that has the potential to get more complicated in the future. Also, there may be a need to synchronize local app data with a PostgreSQL database server.

到目前为止,我已经使用CoreData对象读取,写入和删除数据。我一直在翻译SQL查询以使用CoreData语言,但是发现其中某些查询不必要地麻烦,例如:

So far I have used CoreData objects to read, write and delete data. I've been translating SQL queries to use CoreData language, but have found it unnecessarily cumbersome for some of them, e.g.:

select sum(amount), date from db.table group by date;

这只是一个示例,将来应用程序可能需要更复杂的报告查询。因此,我正在考虑从CoreData切换为直接查询SQLite(我可以使用已经编写的查询来查询PostgreSQL数据库)。

This is just one example and the application will potentially require more complex reporting queries in the future. Because of that I am thinking of switching from CoreData to querying SQLite directly (I could use queries already written to query the PostgreSQL DB).

我的问题是:


  • 考虑到报告是应用程序的核心功能(例如,要求不重要),继续使用CoreData而不是SQL查询是否值得? SELECT查询)?

  • 在同一个存储空间中同时使用SQL(对于复杂的SELECT查询)和CoreData(对于应用程序的其余部分)是否可行?

推荐答案

出于相同的原因,我删除了核心数据,我有一些非常复杂的查询,这太痛苦了进行翻译以供核心数据使用。坚持使用纯SQLLite并手动编写SQL是我认为的方法。或者,您可以将FMDB用作SQLlite的包装器 https://github.com/ccgus/fmdb

I dropped core data for the same reason, I have some pretty complex queries and it was too much of a pain in the butt to translate for use by core data. Just stick with pure SQLLite and writing the SQL out manually is the way to go in my opinion. Alternatively, you can use FMDB as a wrapper for SQLlite https://github.com/ccgus/fmdb

这篇关于CoreData对象或用于复杂报表的SQL语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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