On 04/20/2016 11:21 PM, Cecil Westerhof wrote:
> 2016-04-20 18:07 GMT+02:00 R Smith <rsmith at rsweb.co.za>:
>
>>
>> On 2016/04/20 6:04 PM, Cecil Westerhof wrote:
>>
>>> I am thinking about creating a table where a certain field will be a
>>> description, or a key to the description. Would it be possible to have a
>>> constraint on this field that it is an id, that this id points to an
>>> existing record in a description table?
>>>
>>>
>> https://www.sqlite.org/foreignkeys.html
>
> ?If I read that correctly then a field has to be NULL or point to a record
> in the other table. I want it to point to a record if it is an INT and whem
> it is TEXT it is just the text. (And it should only be allowed to be an INT
> or TEXT.)

I don't think you can use a constraint in SQLite for that. You could 
write a trigger to check that only valid values are inserted into the 
table though (and the corresponding trigger  for updates, and for 
updates and deletes on the referenced table).

Dan.



> ?
>
>   --
> Cecil Westerhof
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to