On 6/16/2016 4:53 PM, Drago, William @ CSG - NARDA-MITEQ wrote:
Say I had a table of apples:

CREATE TABLE Apples (
ID INTEGER PRIMARY KEY,
Color TEXT COLLATE NOCASE, --Could be Red, Green, or Yellow
Height REAL, --Measured in cm
Width REAL --Measured in cm
Weight REAL --Measured in grams
);

And say I had a function that looks at the Apples table and finds groups of 4 
apples that match in color, dimensions, and weight.
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
);

That rather depends on what you plan to do next with this data, what kind of queries you expect to run on it.

These apples are part of a communication system and there will always be 
exactly 4 in each group.

My concern is, from the Groups table how to do I find the number of groups of 
red apples, or groups of green apples that weight approx. 80 grams and are 
approx. 10cm tall without including redundant information from the Apples table?

"Approx 80 grams" doesn't look like redundant information; I assume Apples.Weight may store 79 or 81 for an apple belonging to such a group.
--
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to