SQLite Forum

Mismatch in query results
Login
A couple of notes:

Although I think your definition for <code>PRIMARY KEY</code> will work fine, there are reasons why you might want to define those values slightly differently.  I recommend you take a look at

<https://sqlite.org/faq.html#q1>

Also you can enforce the parent / child relationship using <code>FOREIGN KEY</code>s.  That way your database will not allow such things to happen:

<https://sqlite.org/foreignkeys.html>

However, your data structure is good and you seem to understand how to proceed, so perhaps you're okay without it.