Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS - CoreData or Sqlite suite my app?
    primarykey
    data
    text
    <p>My app have 2 entities (or tables).</p> <p><code>Category (id, name)</code><br> <code>Item (id, name, amount, date, categoryId)</code></p> <p>What I need is</p> <pre><code>SELECT categoryId, Category.name, SUM(IF(MONTH(FROM_UNIXTIME(date)) = 1, amount, 0)) AS jan SUM(IF(MONTH(FROM_UNIXTIME(date)) = 2, amount, 0)) AS feb SUM(IF(MONTH(FROM_UNIXTIME(date)) = 3, amount, 0)) AS mar SUM(IF(MONTH(FROM_UNIXTIME(date)) = 4, amount, 0)) AS apr SUM(IF(MONTH(FROM_UNIXTIME(date)) = 5, amount, 0)) AS may SUM(IF(MONTH(FROM_UNIXTIME(date)) = 6, amount, 0)) AS jun SUM(IF(MONTH(FROM_UNIXTIME(date)) = 7, amount, 0)) AS jul SUM(IF(MONTH(FROM_UNIXTIME(date)) = 8, amount, 0)) AS aug SUM(IF(MONTH(FROM_UNIXTIME(date)) = 9, amount, 0)) AS sep SUM(IF(MONTH(FROM_UNIXTIME(date)) = 10, amount, 0)) AS oct SUM(IF(MONTH(FROM_UNIXTIME(date)) = 11, amount, 0)) AS nov SUM(IF(MONTH(FROM_UNIXTIME(date)) = 12, amount, 0)) AS dec FROM Item INNER JOIN Category ON Item.categoryId = Category.id WHERE YEAR(FROM_UNIXTIME(date)) = 2012 GROUP BY categoryId </code></pre> <p><strong>NOTE: The above query is written in MySQL way, and I'm totally new to CoreData &amp; Sqlite</strong></p> <p>In this situation, CoreData <strong>VS</strong> Sqlite, which 1 is more suitable?</p> <p>How to translate the above sql to CoreData or Sqlite form?</p> <p>Thanks.</p> <h1>Edit</h1> <p>Can I mix both? For <code>CRUD</code> is using <strong>CoreData</strong>, however for such a complex query use <strong>Sqlite</strong><em>(FMDB library)</em>?</p> <p>By default, CoreData has created a file with extension <strong>.sqlite</strong>. However, in <a href="https://github.com/ccgus/fmdb#database-creation" rel="nofollow">FMDB github instruction</a> here is with the extension <strong>.db</strong>. Does it matter?</p> <p>Is the database path <code>[FMDatabase databaseWithPath:@"/tmp/tmp.db"];</code> same as CoreData?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload