Tim,

> Ello all...
> 
> I want to implement a "matrix" style table(s) but not sure 
> how to go about it.  Basically I have a table of "things" 
> that are compatiable with zero or more other "things", e.g.:
> 
>   1 2 3 4 5
> 1   X X
> 2 X     X
> 3 X     X X
> 4   X X   X
> 5     X X
> 
> Now I could have a "matrix" table that contains two keys, but 
> to make sure everything works properly I'd have to have two 
> entries for each pair...

That's the way you'd have to do it...

> Does anyone know of a way to get around this?

The query is actually very quick to return stuff.

SELECT * (or whatever)
FROM Tbl
WHERE x <> y

Because, this would return ALL records where x and y aren't the same
(because if they were, it wouldn't be a matrix).

It's actually really easy to create this type of table and use it (as I
have) and the queries are not a big issue, so long as you use the correct
queries to get everything.

The only other way around it, is to create a second table that contains the
"links" between things.

That way, you have one table of ID's, and a table of "links" and do a
sub-select

SELECT *
FROM tblid
WHERE tblid.idfld IN (SELECT tbllinks.linkids FROM tbllinks WHERE
tbllinks.idfld = tblid.idfld)

Or something like that... You could then do a JOIN (or something) that
returns all the ID's and null if they aren't in the list...

Just some thoughts

Paul



-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to