views:

12

answers:

1

I need the primary keys of 2 sqlite tables (say, id1 and id2) to be related such that no id1 can be equal to any id2 and viceversa. This is because I need to obtain from these 2 tables the same type of xml element, with unique attribute id. Is there a way either in sql as understood by sqlite or in "classic" sql to express such constraints to my id fields? Alternatively, I guess I could create another table with reference to the other 2 and unique id from which I'd take my data... but I'd like to know if it is possible in the other way first, and which is the best practice in this case in your opinion.

Thank you!

A: 

XML ID values technically can't be numbers anyways, so prepend the id with text before storing in XML. Then you don't need to worry about numeric duplicates.

http://www.w3.org/TR/2004/REC-xml-20040204/#NT-Name

[4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender

[5] Name ::= (Letter | '_' | ':') (NameChar)*

Validity constraint: ID

Values of type ID MUST match the Name production. A name MUST NOT appear more than once in an XML document as a value of this type; i.e., ID values MUST uniquely identify the elements which bear them.

Sam