1-
What should I index?

Index is for speed.. Should I mainly index the columns where I do often
searches on them?
Should I index all not null columns event if I rarely search using them?
Should I index enum columns even if there is a lot of identical data.
Will a search using only indexed columns be faster, or it will still go
into the table itself to get the data?

I read some about it in the guide, but still not clear.

2-
Do you think it's better to have 4 small queries or one huge one that
returns tons of lines? Let me explain.

I have let's say, a main table "events" with fields evtID, evtName, etc.
I have 3 smaller tables "outlets", "promoters" and "artists".
Those are "n:n" relations with the events table. An event may have
multiple artists, and an artist may be in multiple events. 

So I created 3 link tables
"eventoutlets" with columns eoEvtID and eoOutID
"eventpromoters" with columns epEvtID and epProID
"eventartists" with columns eaEvtID and eaArtID

So, if you still follow me, I want to get the list of artists playing at
an event, plus the outlets for tickets and the promoters throwing the
event.

I can do a HUGE select statement, or make a couple of small ones.
select epProID from eventpromoters where epEvtID = '3'
select eoProID from eventpromoters where epEvtID = '3'
select eaProID from eventpromoters where epEvtID = '3'

(some script to store those results)

select proName, proInfo from promoters where promoterID = '5' or
promoterID = '6' or promoterID = '12' (etc)

same for the artists, outlets..

ideally, something like
select proName, proInfo from promoters where promoterID = (select
eaProID from eventpromoters where epEvtID = '3')

would be perfect, assuming it selects for all the occurences where
epEvtID is 3 and not just the first one.

Anyways, I'm pretty sure nobody went reading this far, I'd just like
some input as how you're doing your things with n:n tables.

And if you have any mailinglist you know that is more about database
design itself..

Etienne

-- 
Etienne Marcotte
Specifications Management - Quality Control
Imperial Tobacco Ltd. - Montreal (Qc) Canada
514.932.6161 x.4001

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to