Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 15th, 2003, 06:51 PM
DoocesWild22 DoocesWild22 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 16 DoocesWild22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old December 15th, 2003, 10:41 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,829 Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 20 h 23 m 12 sec
Reputation Power: 765
You might try a google search for database normalization.

One of the normalization rules is that you don't have repeating data.

Reply With Quote
  #3  
Old December 16th, 2003, 02:38 PM
madmatt75 madmatt75 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Binghamton, NY
Posts: 22 madmatt75 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Re: multi level DB

Quote:
Originally posted by DoocesWild22
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


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.

Reply With Quote
  #4  
Old December 16th, 2003, 02:46 PM
DoocesWild22 DoocesWild22 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 16 DoocesWild22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
That sounds great but I have no idea what this means:
Quote:
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))

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!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > multi level DB


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway