I am a final year college student, doing my project and I am having some problems with mysql and php. Ok this is my scenario.
I am doing and online store for a health company,first a visitor takes a
nutritional needs assessment where he answers several questions about him self, like the conditions that he has at the moment.What I have is an
array of conditions with 300 conditions in all.This can increase as time goes on.
So the html we have something like this
<input type="checkbox" name="conditions" value="Bad Circulation">
<input type="checkbox" name="conditions" value="Bad Breath">
<input type="checkbox" name="conditions" value="diabetes">
<input type="checkbox" name="conditions" value="asthma">
and so on....reaching 300 for noe
Now here is my problem,if a visitor lets say ticks 15 of these boxes how to we store all 15 in a database.
A couple of option I have is to use the explode/implode of php, but I was told that this is not a normalised database principle and my college Professor will definately penalise me big time.
I am sure what I am looking for is quite simple but I somehow seem to be looking in the wrong place, cause I mean a visitor to another site that sells books could buy 10 books, now I am confused as to how do we store it in a
table, that is normalised off-course.
My problem is this, a visitor can take a nutritioin test now, but if he comes back again in 3 months and does a test, and he selects some of the same
conditions,will it then not have repeating values and a unnormalised
then the test itself would have to be an entity in your database, with a test table, and then the test results would have a foreign key to the test table, thus the same person could take multiple tests
Sorry if I made it seem that way, actually have been trying and it was not working out,I have actually come up with something.I think your many to many relationships above have assisted as well.
This is what I have:-
My problem is that my text book says a many to many relationship is a
symbol of poor database design cause a medication can be depleted by many
nutrients and one nutrient can be a cause for depletion in many medications, causing according to me knowledge a many to many relationship.So I have to (according to my text book) try to make two one-to-many relationships with many-to-many relationships.
Any way , I just want to say thanks for all the help, if you donot reply to me
now , I understand.
that is totally correct, you always implement a many-to-many logical relationship (which is very common and perfectly valid, and almost every database has a many-to-many logical relationship in it somewhere), as two physical one-to-many relationships with a common table
if your textbook did not emphasize the difference between a logical design and a physical design and how to transform the former into the latter, then it is a poor textbook