On 4/25/06, Dick D. email@example.com wrote:
throwing all results into a variable, with no redundant info.
no, you should keep the tables separate, to prevent redundancy. ie, if
use one table such as Music, it may look like this:
id | band | album | label
1, band1, album_a1, label1
2, band1, album_a2, label1
3, band1, album_a3, label1
4, band2, album_b1, label1
5, band2, album_b2, label2
6, band2, album_b2, label2
notice that band1 is repeated and label1 is repeated quite a few times.
Also, if you wanted to change the name of label1 to “Label 1”, you may
to update thousands of rows (depending upon how large your table is).
you keep them separate, the schema would look like the following:
bands: (I would probably rename this table to ‘artists’)
id | band_name |
id | album_name | band_id
1, album_a1, 1
2, album_a2, 1
3, album_a3, 1
4, album_b1, 2
5, album_b2, 2
id | label_name
bands_labels (join table)
band_id | label_id
and your models would look like:
has_and_belongs_to_many: labels (since a band can switch from one label
another during their lifetime)
hopefully this will help you get started.