Pretend you have an xml.file with 80 products in a shop.(it will be a feed but i don't want to confuse the question)
The 80 products have many elements like
<product>
<price> millions </price>
<colour> red </colour>
<pictures> <pic> picture1_url </pic> <pic> picture2_url </pic>
<pic>picture3_url </pic>
</pictures>
</product >
Your client wants to use the .xml on a webpage/app where his customers can search the data by price and colour with a search form and view the 'many' pictures that are nested into the main element 'product'.
My question is: Should i save the data in relational table with columns for each element( relational because there are many pictures which i presume will need to be foreign keyed to the id of product.
I have been able to use dom/ simple_xml to echo the products on a page without the need for a database but i have a nagging feeling i should put the data into a db so i query it easier with mysql select statements.
I Even spoke to a dev and saw on wordpress meta tables that url's for the pictures were kept comma seperated in one table. I thought this was very bad practice in db land?
Trouble is it seems very difficult to attach a foreign key to 1 id when i have many other pictures to associate with that id.. ( get last id seems to get confused when foreach / looping the products.
Here is my code but i suppose its useless if i decide to go dom route and dont need to put the data in a dbase.
$xml = simplexml_load_file('products.xml') or die("can not find it");
foreach($xml->product as $row){
$price = $row->price
$colour =$row->colour
$pictures = $row->pictures
$sql= insert into products table
}