I’ve declared a type similar to the following.
type
TLikes = record
Name : string[20];
favColours : array of string[20];
faves = array of TLikes;
Once the records are populated I save them to a binary file so the structure is like that shown below.
[John], [Green] [White] [Blue]
[Paul], [Blue] [Red] [White] [Green]
[David], [Red] [Blue] [Green]
[Bob], [White] [Blue]
[Peter], [Blue] [Green] [Red]
It’s easy to find out what colours David, for example, likes. A small problem occurs when I want the to know who likes blue. So what I’ve done is build a second file, like so …
[Blue], [John] [Paul] [David] [Peter] [Bob]
[Red], [David] [Paul] [Peter]
[White], [Bob] [David] [John] [Paul]
[Green], [John] [David] [Paul] [Peter]
But something is telling me, I shouldn’t really need to create a second file / data structure, it just seems inefficient.
Here’s a bigger issue ….
What if I need to find who likes any combination of what David likes? My results would be …
Blue and red and green = Paul, David, Peter
Blue and red = Paul, David, Peter
Blue and green = John, Paul, David, Peter
Red and Green = Paul, David, Peter
My question is.
Is there a better way to structure the data / records so I can figure out what Bob and Paul have in common (Blue and White) or what red and white have in common (David and Paul) ?
I guess I need to point out that I have tried to simplify the example above. In reality the data for Tlikes.Name will be strings like …
‘decabbadc’
‘bacddbcad’
‘eebadeaac’
There are something in the order of 200k+ of these strings. And the Tlikes.FavColours data is a filename (there are around 2k of these files). The file name indicates a file that contains the Tlikes.Name string.
I want to be able to retrieve a list of file names given a Tlikes.Name string or a list of strings given a file name.
NB – Something is drawing me to ‘sets’ but from the little I understand, I’m limited in the number of elements in sets, am I on the right track ?
Thank you for taking the time to read the post.
See Question&Answers more detail:
os