I am often faced with the dilemma of whether to use a JOIN query across
three tables in order to grab a bunch of results - or whether to create
another table to represent what I want. The latter is less normalised,
but seems less computationally expensive to me(?).
Basicially what I have is:
Friend (uid1,uid2,fid) -> FriendshipCateg ories(fid,cid) ->
Categories(cid, name)
If I want to find out all the 'categories' (names) which a user has
previously selected.
The fully normalised method would be, presumably, to do a join across
those three tables. However alternatives include creating another table
(let's say "MyCategori es") to map my UID to CID, thus allowing me to do
my lookup by simply JOINing two tables. I can also simply include UID
inside "categories " - but thus resulting in repeated entries of what
may well be the same category. I like this idea the least.
The question is - how much slower is it to use the first method
(joining all three) vs. my compromise solution #2.
Any insight would be appreciated!
Thanks,
Terence
three tables in order to grab a bunch of results - or whether to create
another table to represent what I want. The latter is less normalised,
but seems less computationally expensive to me(?).
Basicially what I have is:
Friend (uid1,uid2,fid) -> FriendshipCateg ories(fid,cid) ->
Categories(cid, name)
If I want to find out all the 'categories' (names) which a user has
previously selected.
The fully normalised method would be, presumably, to do a join across
those three tables. However alternatives include creating another table
(let's say "MyCategori es") to map my UID to CID, thus allowing me to do
my lookup by simply JOINing two tables. I can also simply include UID
inside "categories " - but thus resulting in repeated entries of what
may well be the same category. I like this idea the least.
The question is - how much slower is it to use the first method
(joining all three) vs. my compromise solution #2.
Any insight would be appreciated!
Thanks,
Terence
Comment