Yes, you're exactly right. Try and think of how many times you query the same set of tables; you may do
$query = 'SELECT field1, field2 FROM table';
$query = 'SELECT field1,field2,table2.field3 FROM table LEFT JOIN table2 ON (table1.primary = table2.foreign)';
$query = 'SELECT field1,field2,table2.field3 FROM table LEFT JOIN table2 ON (table1.primary = table2.foreign) WHERE field2 LIKE '%AS%';
And so on and so on.
Depending on your application, it may be better to have some kind of super query -
$query = 'SELECT table1.field1,table1.field2,table1.field3,table1.field4,table2.field1,table2.field2,table2.field3,table2.field4,table2.field5,table3.field1,table3.field2,table3.field3,table3.field4 FROM table1 LEFT JOIN table2 ON (table1.primary = table2.foreign) LEFT JOIN table3 ON (table2.primary = table3.foreign) ORDER BY table1.field1';
Chunk this down to an XML result then use different XSLT sheets depending on the page requirement, remember you can use XSLT selectively, so you could just display 1 or 2 records, or just certain fields.
It also has benefits if you send your content out to other applications, so now you're using one XML chunk to build an XHTML page and the same chunk to generate two RSS feeds and a feed to suppliers database.
The other thing to remember is, it's only the first user that takes the hit on performance, they generate the chunk and the complete XHTML for that page and any other pages which use the same data.
If you're going to go to the effort to safe hits on the DB, you may as well go to town.
But I'm still confused on how to store my content in the DB, should it have HTML tags or should I add some kind of pseudo tags, if I'm storing images seperately
<page_content>
<title>My Title</title>
<author>Me</author>
<author_email>me@.com<author_email>
<summary>This is a summary of this article</summary>
<body>This is my body text, I really want to add an image in here, should I use an img src tag or should I have a seperate element?</body>
<images>
<image>
<name>myimage.jpg</name>
<size>46kb</size>
<height>10</height>
<width>20</height>
<alt>This is an image</alt>
</image>
</images>
</page_content>
If I'm having seperate image element (which makes sense in theory) how do I then get this in to the body content when I output it in HTML?
Anyone ?