
Originally Posted by
Cups
Cons of not doing what you plan:
If you change an image title you have to alter all the corresponding text in the articles.
If you change the way an image is displayed you have to alter all the corresponding text in the articles.
You cannot easily find out how often an image is displayed.
You cannot easily find out which images are not being used.
Cups,
Thanks for the response!
You make some very valid points, however, I'm not sure I did a good job describing the larger issue here... (Actually, there are 4 questions I have on this topic...)
Off Topic:
BTW, I thoroughly understand Database Normalization, but my questions relate more to how to store the data separately and then merge it back together for display. And for this version of my website, I an NOT ready to jump into OOP or MVC, which may be part of the reason this question is so confusing to me...
Let me step back and try to explain things again... 
Issue #1:
How much overhead am I adding to my Web Pages (and Website) by having to query one or more Images for *every* Article (versus just hard-coding them)?
If my website becomes wildly popular, will I be crying in 6 months because while this decision "normalized" things more, it also has brought my website to a grinding halt?! 
Issue #2:
Currently I have the same information in 2 fields in the Article table... (What I described in my original post.)
Obviously this wasn't such a great job, but it served its purpose for my first go-round?!
image field (Used for "Article Summary")
Code:
<img class="noborder" src="/images/PostageMeter.png" width="150" alt="Picture: Postage Meter. Credit: John Doe, Wikimedia Commons." title="Picture: Postage Meter. Credit: John Doe, Wikimedia Commons." />
body field (Used to create the "Article")
Code:
<img class="noborder" src="/images/PostageMeter.png" width="150"
alt="Picture: Postage Meter. Credit: John Doe, Wikimedia Commons."
title="Picture: Postage Meter. Credit: John Doe, Wikimedia Commons." />
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus suscipit mattis laoreet. Quisque convallis elementum scelerisque. Nullam accumsan, purus in condimentum placerat, eros lorem pellentesque justo, eget ullamcorper purus felis et magna. Mauris blandit feugiat semper.</p>
<h3>Time is Money!</h3>
<p>Proin viverra vestibulum velit quis dapibus. Maecenas mattis mauris id eros mollis nec venenatis est faucibus. Maecenas fringilla eleifend tellus, vitae gravida purus rutrum non.</p>
Issue #3:
If I broke out the Article Image to another table and created a many-to-many, I understand how to create a function that queries the data and builds the Image HTML for my "Article Summary".
However, this isn't so easy for the "Article Body", because I have the *single* Article Image embedded in the "body" field.
I would need a way to query the Article Info, then build the Article HTML, and then merge into the existing Article HTML.
Like shown above, an Article currently looks like this...
Code:
<img class="noborder" src="/images/PostageMeter.png" width="150"
alt="Picture: Postage Meter. Credit: John Doe, Wikimedia Commons."
title="Picture: Postage Meter. Credit: John Doe, Wikimedia Commons." />
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus suscipit mattis laoreet. Quisque convallis elementum scelerisque. Nullam accumsan, purus in condimentum placerat, eros lorem pellentesque justo, eget ullamcorper purus felis et magna. Mauris blandit feugiat semper.</p>
and so on...
Maybe I could use something like was recommended in my other thread Trying to store PHP in MySQL? 
Issue #4:
The "Article Image" that I have been talking about is the main Image for an Article, and - if one exists - would be used in the "Article Summary" and "Article Body".
However, down the road it is my goals to have several Images in each Article, so that things read like a magazine article (e.g. Time, Newsweek, etc.)
With that being said, I again understand how to break things up in my database (i.e. many-to-many), however, I do NOT understand how put things back together in the Article.
Off Topic:
BTW, I explicitly decided to place my marked up Article into MySQL, because there is no way to create a "template" for the mark up. Each Article is unique, and needs a "human touch" with me deciding how I want the layout and semantics to come together!!
It is easy to have my Text/HTML in MySQL.
Where it gets complicated, is how would I store the "Article" and the "Images" in separate places and then "build" the finished product?!
Again, maybe the link to the thread above could be modified to make things work, but since the # of Images will vary from 0 to 1 to many in each Article, I am not sure how to apply the logic I used for One Image to Many Images in One Article?! 
Hope all of that makes sense?!
Thanks,
Debbie
Bookmarks