|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
multi level DB
Hi, I am trying to make a DB with multiple levels, but I don't know if I should make one big huge table, or many many little tables. I have never built a DB before and really want to learn. Right now I have a table that has
-artist -album -title -genre -year produced -lyrics So if an artist has more than one title, I just list the album again, etc. Would it be smarter to make a database for artist, then another for album, then another for each song with the lyrics on that one table? If so, where do I learn how to link these together. My main problem is that I'm using Cold Fusion to search through the lyrics portion, and I need to be able to search all of the lyrics as a whole, so I cannot split those up... Anything to help would be great. Thanks |
|
#2
|
|||
|
|||
|
You might try a google search for database normalization.
One of the normalization rules is that you don't have repeating data. |
|
#3
|
|||
|
|||
|
Re: multi level DB
Quote:
Lets split your "flat" table into 4 tables create table Artist(artist_id int primary key, artist_name varchar(100)) create table Album(album_id int primary key, genre_id int, year_produced datetime) create table Song(song_id int primary key, album_id int, artist_id_int, title varchar(100), lyrics text) create table genre(genre_id int primary key, genre_name varchar(100)) When you create a database you need to make some assumptions about the data. I assumed the following: 1. An album can have one or many artists and one or many songs. But only one Genre. 2. A song can belong to only one artist and only one album. Fields marked as primary key need to be unique. Fields that end in _id are foreign keys meaning they link to another table. If my assumptions are incorrect (I'm not in the music industry) then you'll need to make adjustments to the structure. Hopefully this gets you started. If all this is more than you want to get into, then leave all your songs in one big table like you have now. Matt. |
|
#4
|
|||
|
|||
|
That sounds great but I have no idea what this means:
Quote:
and so on.... I'm very very new to this, so any specifics would be great. I can understand that I need to make primary keys in each category, but how do I make the secondary keys and how do I link them together (I'm using coldfusion) I know this is super basic, so thanks for spending your time answering this! |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > multi level DB |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|