Re: Simple Database Design Problem
Posted by: Rick James
Date: June 11, 2011 09:18AM

Yes...
FROM templates
LEFT JOIN page_templates ON ...
LEFT JOIN template_page_templates ON ...
would give you all the info from whichever table is needed, plus NULLs from the other table.

Is this the best way? It feels clumsy. I don't have a good feel for what your design is. I presented this another approach.

In general, I recommend
1. Find the "entities" in your data.
2. Build the relations between them, either by ids (1-many and many-1), or by relation tables (many-to-many).
3. Sometimes, add attributes to the Relation tables.
4. "Normalize" out repeated info (there should not be much, if you have done #1 correctly). In large tables, don't normalize out so much that performance will be bad.
5. Design the SELECTs.
6. From the SELECTs, it should be 'obvious' what INDEXes to have. Be sure to use "compound indexes" where appropriate. (The 'Performance' forum is littered with my comments on indexing.)
29. Plan on making major schema changes after a few months. (Your business requirements will change; performance will necessitate changes; etc.)

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.