Joining tables i think
Moderator: General Moderators
Joining tables i think
Ok im not sure what to do here. i dont know if joining tables will work. Ive got 1 table which is called "Days" its got dayID, DayName and BandID. then ive got a table called "Bands" with BandID, BandName, BandDescription. the days is just filled with Sunday to Saturday and every week that table is updated to change what band from a pool of bands will be playing that week. i just need to create a html table which pulls the days name out of the days table then checks the bandid then inserts into the html table the band name and description. whats the best way to do this?
Re: Joining tables i think
yes, join between the 2 tables will work... the easy way: create a view in the database joining the 2 tables and in you php/html just make reference to the view.
In another note, your model could be improved if you have 3 tables instead of 2.
Table Days:
DayId
DayName
Table Bands:
BandId
BandName
BandDescription
Table DaysBands: (This table represent the relation between a day and the band(s) playing any given day)
DayId
BandId
Hope this help
Miko
In another note, your model could be improved if you have 3 tables instead of 2.
Table Days:
DayId
DayName
Table Bands:
BandId
BandName
BandDescription
Table DaysBands: (This table represent the relation between a day and the band(s) playing any given day)
DayId
BandId
Hope this help
Miko
Re: Joining tables i think
with 3 tables wont that make it harder to join?
Re: Joining tables i think
just a little... but your business model will improve... in your original model per example you can have more than one band playing the same day, but the DayName need be duplicated in your table Days (with different IDs).. in the second model with 3 tables the Days are present only one time, hence give you more clarity and flexibility and save space in you database.Da_Elf wrote:with 3 tables wont that make it harder to join?
Your model is small and probably you can live with the way that you are implementing it... but in bigger systems/models where you manage thousands of records the space and your model flexibility is important.
Miko
Re: Joining tables i think
actually i didnt need to do any joining. all i needed to do was use
then in the "while" loop i just pulled band id from the Days table and used it in another seach
then used that search to pull up the band info then close the loop
Code: Select all
"Select * From Days Order By DayID ";Code: Select all
$bid = $row['BandID'];
"Select * From Bands WHERE BandID = '$bid' ";Re: Joining tables i think
it works... maybe I did read your original post wrongly... I understood that you were asking for "the best way to do this"Da_Elf wrote:Ok im not sure what to do here........... whats the best way to do this?
but if your solution work for you is fine
Miko