On 16 Jun 2016, at 9:53pm, Drago, William @ CSG - NARDA-MITEQ <william.dr...@l-3com.com> wrote:
> Should that function insert its results into a table that looks like the one > below, or is there a better way? > > CREATE TABLE Groups ( > ID INTEGER PRIMARY KEY, > AppleID1 INTEGER > AppleID2 INTEGER > AppleID3 INTEGER > AppleID4 INTEGER > ); You would definitely want each of the four AppleIDs to have a FOREIGN KEY reference to the Apple table. An alternative to your Groups table would be a Membership table: CREATE TABLE Members ( AppleID INTEGER, GroupID INTEGER, FOREIGN KEY (AppleID) REFERENCES Apples(ID) ); It is the responsibility of your software to ensure that every GroupID appears exactly four times in Members. This would allow you to create another table, Groups, which stored things like the group's colour and total weight. And this should be a foreign key reference for the Members table too. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users