On Wed, Jan 31, 2007 at 05:23:29PM -0500, Shane Harrelson wrote:
> 
> I have two tables, an "Objects" table with a foreign key into a second
> "Strings" table which is composed of unique values.  It is a many to
> one relationship, that is, several Objects may reference the same
> String.   When an Object is added, its associated String is added to
> the Strings table.   If the String already exists in the Strings
> table, I'd like the new Object to reference the existing copy.
> 
> Currently, I've implemented it as so (leaving out error handling, etc.):
> 
> begin transaction
> insert into Strings (value) VALUES ( 'foo')
> if string insert result is SQLITE_OK

Sounds like you should want to use INSERT OR IGNORE ... INTO Strings and
then SELECT the rowid of the string for use in INSERTing INTO Object.

Nico
-- 

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to