<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: SQLite Persistent Objects</title>
	<atom:link href="http://iphone.galloway.me.uk/2009/02/sqlite-persistent-objects/feed/" rel="self" type="application/rss+xml" />
	<link>http://iphone.galloway.me.uk/2009/02/sqlite-persistent-objects/</link>
	<description>iPhone Applications</description>
	<lastBuildDate>Fri, 05 Mar 2010 14:03:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Matt Galloway</title>
		<link>http://iphone.galloway.me.uk/2009/02/sqlite-persistent-objects/comment-page-1/#comment-470</link>
		<dc:creator>Matt Galloway</dc:creator>
		<pubDate>Mon, 04 Jan 2010 21:16:17 +0000</pubDate>
		<guid isPermaLink="false">http://iphone.galloway.me.uk/?p=92#comment-470</guid>
		<description>Hi Brian,

Thanks for the comment. I haven&#039;t used SLPO for a while, but I really thought you could just use an NSArray as a property to create a 1-to-many relationship. Have you tried that&gt;

Matt</description>
		<content:encoded><![CDATA[<p>Hi Brian,</p>
<p>Thanks for the comment. I haven&#8217;t used SLPO for a while, but I really thought you could just use an NSArray as a property to create a 1-to-many relationship. Have you tried that></p>
<p>Matt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://iphone.galloway.me.uk/2009/02/sqlite-persistent-objects/comment-page-1/#comment-466</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Mon, 04 Jan 2010 04:55:34 +0000</pubDate>
		<guid isPermaLink="false">http://iphone.galloway.me.uk/?p=92#comment-466</guid>
		<description>Hi Matt, 
I was wondering if you could shed some light on how to setup a has_many relationship using SQlite Persistent Objects.  I&#039;ve been looking into this for quite a while and can&#039;t find any good information.  I think I understand the belongs_to relationship where you just specify another SLPO as a property but not sure how to get the 1-to-many collection, wether you need to setup your own method to return an array (in which case how to setup the WHERE statement), or if this is somehow already built in (I didn&#039;t see it in the source).

Thanks!</description>
		<content:encoded><![CDATA[<p>Hi Matt,<br />
I was wondering if you could shed some light on how to setup a has_many relationship using SQlite Persistent Objects.  I&#8217;ve been looking into this for quite a while and can&#8217;t find any good information.  I think I understand the belongs_to relationship where you just specify another SLPO as a property but not sure how to get the 1-to-many collection, wether you need to setup your own method to return an array (in which case how to setup the WHERE statement), or if this is somehow already built in (I didn&#8217;t see it in the source).</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jack</title>
		<link>http://iphone.galloway.me.uk/2009/02/sqlite-persistent-objects/comment-page-1/#comment-73</link>
		<dc:creator>Jack</dc:creator>
		<pubDate>Fri, 19 Jun 2009 07:06:17 +0000</pubDate>
		<guid isPermaLink="false">http://iphone.galloway.me.uk/?p=92#comment-73</guid>
		<description>Thanks Matt,  I&#039;ll check.</description>
		<content:encoded><![CDATA[<p>Thanks Matt,  I&#8217;ll check.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Galloway</title>
		<link>http://iphone.galloway.me.uk/2009/02/sqlite-persistent-objects/comment-page-1/#comment-72</link>
		<dc:creator>Matt Galloway</dc:creator>
		<pubDate>Fri, 19 Jun 2009 06:48:18 +0000</pubDate>
		<guid isPermaLink="false">http://iphone.galloway.me.uk/?p=92#comment-72</guid>
		<description>Hi Jack,

I&#039;m not sure if SQLite really does have foreign keys, check out http://www.sqlite.org/omitted.html . There&#039;s lots of people which mention how to do foreign key constraints (properly) using triggers.

That&#039;s a good idea to ask Jeff, but also, take a look in the source code itself (the file of interest is http://code.google.com/p/sqlitepersistentobjects/source/browse/trunk/src/SQLitePersistentObject.m). You&#039;ll notice that it creates a cross reference table to do the &quot;foreign key&quot; behaviour.

I still don&#039;t quite know why you are having issues with it, it will work exactly as you expect by only having to store things once.

Matt</description>
		<content:encoded><![CDATA[<p>Hi Jack,</p>
<p>I&#8217;m not sure if SQLite really does have foreign keys, check out <a href="http://www.sqlite.org/omitted.html" rel="nofollow">http://www.sqlite.org/omitted.html</a> . There&#8217;s lots of people which mention how to do foreign key constraints (properly) using triggers.</p>
<p>That&#8217;s a good idea to ask Jeff, but also, take a look in the source code itself (the file of interest is <a href="http://code.google.com/p/sqlitepersistentobjects/source/browse/trunk/src/SQLitePersistentObject.m)" rel="nofollow">http://code.google.com/p/sqlitepersistentobjects/source/browse/trunk/src/SQLitePersistentObject.m)</a>. You&#8217;ll notice that it creates a cross reference table to do the &#8220;foreign key&#8221; behaviour.</p>
<p>I still don&#8217;t quite know why you are having issues with it, it will work exactly as you expect by only having to store things once.</p>
<p>Matt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jack</title>
		<link>http://iphone.galloway.me.uk/2009/02/sqlite-persistent-objects/comment-page-1/#comment-78</link>
		<dc:creator>Jack</dc:creator>
		<pubDate>Thu, 18 Jun 2009 20:28:39 +0000</pubDate>
		<guid isPermaLink="false">http://iphone.galloway.me.uk/?p=92#comment-78</guid>
		<description>Matt, of course SQLite has foreign keys, as any relational DB. :) I asked about foreign keys because if I use them in my particular application, it&#039;ll give me huge advantage (I&#039;ll store only unique data (such as countries, or a currencies) and at the downloads table will be contain only references to them (integers)). It&#039;s more convenient, than just store, all bunch of data.

By the way, i have dropped email to Jeff (author of the SQLitePersistentObject), but looks like he went to the WWDC, I&#039;ll update you with info when I receive reply.</description>
		<content:encoded><![CDATA[<p>Matt, of course SQLite has foreign keys, as any relational DB. <img src='http://iphone.galloway.me.uk/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I asked about foreign keys because if I use them in my particular application, it&#8217;ll give me huge advantage (I&#8217;ll store only unique data (such as countries, or a currencies) and at the downloads table will be contain only references to them (integers)). It&#8217;s more convenient, than just store, all bunch of data.</p>
<p>By the way, i have dropped email to Jeff (author of the SQLitePersistentObject), but looks like he went to the WWDC, I&#8217;ll update you with info when I receive reply.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Galloway</title>
		<link>http://iphone.galloway.me.uk/2009/02/sqlite-persistent-objects/comment-page-1/#comment-77</link>
		<dc:creator>Matt Galloway</dc:creator>
		<pubDate>Thu, 18 Jun 2009 12:14:06 +0000</pubDate>
		<guid isPermaLink="false">http://iphone.galloway.me.uk/?p=92#comment-77</guid>
		<description>Hi Jack,

Yes, that&#039;s right. SQLite doesn&#039;t have foreign keys. It will store it as a text field and in that field it will store something which SQLitePersistentObject knows how to find the relevant object in the other table. Does that make sense?

Does it work for you? i.e. can you save and load objects correctly?

Matt</description>
		<content:encoded><![CDATA[<p>Hi Jack,</p>
<p>Yes, that&#8217;s right. SQLite doesn&#8217;t have foreign keys. It will store it as a text field and in that field it will store something which SQLitePersistentObject knows how to find the relevant object in the other table. Does that make sense?</p>
<p>Does it work for you? i.e. can you save and load objects correctly?</p>
<p>Matt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jack</title>
		<link>http://iphone.galloway.me.uk/2009/02/sqlite-persistent-objects/comment-page-1/#comment-76</link>
		<dc:creator>Jack</dc:creator>
		<pubDate>Thu, 18 Jun 2009 11:41:54 +0000</pubDate>
		<guid isPermaLink="false">http://iphone.galloway.me.uk/?p=92#comment-76</guid>
		<description>Matt, of course Car is the subclass of SQLLitePersistentObject.

In my real app, I have four classes (Application, Country, Currency, Downloads)

Downloads, contains references to Application, Country and Currency, here is example:

@interface Downloads : SQLitePersistentObject {
    Application *application;
    Country *country;
    Currency *currency;
    float royalty;
    int units;
    int isUpdate;
    NSDate *date;
    NSString *appId;
}
@property (nonatomic, retain) Application *application;
@property (nonatomic, retain) Country *country;
@property (nonatomic, retain) Currency *currency;
@property (assign) float royalty;
@property (assign) int units;
@property (assign) int isUpdate;
@property (nonatomic, retain) NSDate *date;
@property (nonatomic, retain) NSString *appId;
@end

Example of Application class:

@interface Application : SQLitePersistentObject {
    NSString *name;
}
@property (nonatomic, retain) NSString *name;
@end

And here is DB Schema created by SQLitePersistent

CREATE TABLE downloads (pk INTEGER PRIMARY KEY, application TEXT, app_id TEXT, is_update INTEGER, royalty REAL, currency TEXT, country TEXT, date REAL, units INTEGER)

application, currency and country are TEXT field, no foreign keys created. What I&#039;ve done wrong?

Thanks in advance.</description>
		<content:encoded><![CDATA[<p>Matt, of course Car is the subclass of SQLLitePersistentObject.</p>
<p>In my real app, I have four classes (Application, Country, Currency, Downloads)</p>
<p>Downloads, contains references to Application, Country and Currency, here is example:</p>
<p>@interface Downloads : SQLitePersistentObject {<br />
    Application *application;<br />
    Country *country;<br />
    Currency *currency;<br />
    float royalty;<br />
    int units;<br />
    int isUpdate;<br />
    NSDate *date;<br />
    NSString *appId;<br />
}<br />
@property (nonatomic, retain) Application *application;<br />
@property (nonatomic, retain) Country *country;<br />
@property (nonatomic, retain) Currency *currency;<br />
@property (assign) float royalty;<br />
@property (assign) int units;<br />
@property (assign) int isUpdate;<br />
@property (nonatomic, retain) NSDate *date;<br />
@property (nonatomic, retain) NSString *appId;<br />
@end</p>
<p>Example of Application class:</p>
<p>@interface Application : SQLitePersistentObject {<br />
    NSString *name;<br />
}<br />
@property (nonatomic, retain) NSString *name;<br />
@end</p>
<p>And here is DB Schema created by SQLitePersistent</p>
<p>CREATE TABLE downloads (pk INTEGER PRIMARY KEY, application TEXT, app_id TEXT, is_update INTEGER, royalty REAL, currency TEXT, country TEXT, date REAL, units INTEGER)</p>
<p>application, currency and country are TEXT field, no foreign keys created. What I&#8217;ve done wrong?</p>
<p>Thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Galloway</title>
		<link>http://iphone.galloway.me.uk/2009/02/sqlite-persistent-objects/comment-page-1/#comment-75</link>
		<dc:creator>Matt Galloway</dc:creator>
		<pubDate>Thu, 18 Jun 2009 08:12:04 +0000</pubDate>
		<guid isPermaLink="false">http://iphone.galloway.me.uk/?p=92#comment-75</guid>
		<description>Hi Jack,

One thing to note, in order for SQLLitePersistentObject to save a link to another object, that other object must also be a subclass of SQLLitePersistentObject, or at least some type of object which it knows how to save (Number, Data, String, etc).

Can you check that Car is a subclass of SQLLitePersistentObject as well please?

Thanks,
Matt</description>
		<content:encoded><![CDATA[<p>Hi Jack,</p>
<p>One thing to note, in order for SQLLitePersistentObject to save a link to another object, that other object must also be a subclass of SQLLitePersistentObject, or at least some type of object which it knows how to save (Number, Data, String, etc).</p>
<p>Can you check that Car is a subclass of SQLLitePersistentObject as well please?</p>
<p>Thanks,<br />
Matt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jack</title>
		<link>http://iphone.galloway.me.uk/2009/02/sqlite-persistent-objects/comment-page-1/#comment-74</link>
		<dc:creator>Jack</dc:creator>
		<pubDate>Thu, 18 Jun 2009 00:21:03 +0000</pubDate>
		<guid isPermaLink="false">http://iphone.galloway.me.uk/?p=92#comment-74</guid>
		<description>How to create foreign key in your Person model to for example Car model?

I tried to use something like this


@interface Person : SQLitePersistentObject  {
	Car *car;
        // .... your code ....
}
@property (nonatomic, retain) Car *car;
// .... your code ....
@end

However SQLitePersistent doesn&#039;t create any references, just TEXT fields, and store there [car description] as I suppose.


Any ideas how to create real foreign key to another model?

Thanks in advance.</description>
		<content:encoded><![CDATA[<p>How to create foreign key in your Person model to for example Car model?</p>
<p>I tried to use something like this</p>
<p>@interface Person : SQLitePersistentObject  {<br />
	Car *car;<br />
        // &#8230;. your code &#8230;.<br />
}<br />
@property (nonatomic, retain) Car *car;<br />
// &#8230;. your code &#8230;.<br />
@end</p>
<p>However SQLitePersistent doesn&#8217;t create any references, just TEXT fields, and store there [car description] as I suppose.</p>
<p>Any ideas how to create real foreign key to another model?</p>
<p>Thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Forsworn</title>
		<link>http://iphone.galloway.me.uk/2009/02/sqlite-persistent-objects/comment-page-1/#comment-71</link>
		<dc:creator>Forsworn</dc:creator>
		<pubDate>Wed, 25 Feb 2009 17:08:55 +0000</pubDate>
		<guid isPermaLink="false">http://iphone.galloway.me.uk/?p=92#comment-71</guid>
		<description>Yeah, I&#039;m using it in my current (actually next) app and it&#039;s really great and that easy!</description>
		<content:encoded><![CDATA[<p>Yeah, I&#8217;m using it in my current (actually next) app and it&#8217;s really great and that easy!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
