[odb-users] FK relationships

Tony Rietwyk tony at rightsoft.com.au
Mon Jun 19 19:01:52 EDT 2017


> Sent: Tuesday, 20 June 2017 5:08 AM
> 
> Hi
> 
> I’m trying to achieve this simple structure but cannot get my head around
> this.
> 
> A table with
> 
> CREATE TABLE Asset (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT
> UNIQUE, asset TEXT NOT NULL UNIQUE PRIMARY KEY);

That can't possibly work - if you want multiple columns with primary key, then AFAIK you have to use the table primary key syntax.  

But I suspect that don't want it, since the other tables are only referring to Asset(id) in their foreign keys.  In that case, just remove the "PRIMARY KEY" from the Asset.asset field.  

I also think you should have more distinct field names - I would hate to maintain your code where "asset" is a table name, a text field within that table, and an integer field in referring objects!  

Regards, Tony





More information about the odb-users mailing list