I have one table:
horse
->id
->course
->date
Another one:
course
->title
->trackstyle
And a third one
trackstyle
->id
->style
The style for the course can be multiple, so I thought I will create a field and save the value(s) delimited with a comma.
ie:
trackstyle
id:1
style:galloping
id:2
style:flat
course
title:ascot
trackstyle:1,2 (as it's galloping and flat)
title=beverley
trackstyle:1 (as it's just flat)
Now, I have trouble to build a request that will query all three tables …
Is it the correct way to build my database?
Or should I just add a new column in my course table, where I will put the trackstyle in ‘hard’:
course
title: ascot
trackstyle: galloping, flat
title: beverley
trackstyle: flat
No this is not a good way to build the Database. Instead you have to do something like following
And one join table
Your query will be something like following