01-08-15, 16:05 #1Registered User
- Join Date
- Jan 2015
Unanswered: Best Way To Use XML Dynamically With MySQL
I am using MySQL for the back end database for my website and I would like to design my database to work like this:
The table is set up with generic fields and a field labeled TYPE. (NOTE All generic field types will be String, 255 chars just to make things easy).
The user selects a data entry 'Type' from a dropdown and enters data.
Based on the Type selected in the dropdown the database should use an XML file that will know what is in each generic field.
User selects 'fruit' from the type and the data entered is for a 'banana'.
The xml file for fruit might look like this:
<fruit> <colors></colors> <shape></shape> <skintype></skintype> <locations></locations> <seeds></seeds> </fruit>
In the above example the database would be populated with:
fruit, banana, yellow|green, long|cylindrical, peel, tropical areas, very tiny seeds
Another selection Type might be 'actors' and the xml will be as follows:
<actors> <movies></movies> <tv></tv> <directed></directed> <datebirth></datebirth> <datedeath></datedeath> </actors>
actors, Bryan Cranston, Godzilla|Argo|Drive, Breaking Bad|Malcolm In The Middle, 3/7/1965, N/A
My question is this: Can I save my xml files within my database? Is that the best way? What is the best way?
I actually have been working with MySQL for some time, but I have not been using xml that long. I get the general idea and thought it would work well for this particular database I am creating.
Thank you very much.
01-09-15, 05:51 #2Jaded Developer
Provided Answers: 59
- Join Date
- Nov 2004
- out on a limb
best way in my books its not to use XML for storage, but then again I wouldn't use this EAV model for data storage within a relational DB. i
its a very attractive model if:_
you don't expect there to be too much data,
you don't expect to need to do that much searching or data manipulaiton,
you don't give a fig for performance / database server usage.
your intended consumption of the data is linear (IE you know now precisley how the data will be consuimed in, say a book / published form.
But frankly its pretty awful if you need to start searching for data, finding common elements and so on.
far better to design the db properly using realtional dataabse principles, or don't use a relational DB at all
MySQL does have a set of fucntion for using XML
https://www.google.co.uk/webhp?sourc...-8#q=mysql+xmlI'd rather be riding on the Tiger 800 or the Norton