Hi,
I am a SQL and databases newbie and this might seem like a really simple question but I just can't seem to get my head around the concept. I'm building a C# music database app. that manages music files but I am having serious trouble wrapping my head around the initial inserts of all the music MP3s on a hard drive - how do I do the inserts?
I am using the following tables (I have simplified them):
ARTIST table
ARTISTID (PK)
ARTISTNAME
ALBUM table
ALBUMID (PK)
ARTISTID (FK)
ALBUMTITLE
TRACKALBUM
TRACKID(PK)
ALBUMID(FK)
TRACKNUMBER
TRACK
TRACKID
TRACKTITLE
So whats the best way to go about inserting new tracks into this database? I realise this is probably a very simple thing but any help would be VERY MUCH APPRECIATED as this is one of the core functions of my app.
Hi,
The concept of having Foreign key relationships is that you need to have the entry in the parent table to put a referecing key entry in the child table. I would suggest building the tables top-down
1. First populate the Artist table
2. Next populated the Album table and so on
With the referential integrity in place, this would ensure that you do not insert anything in the child table that is not there in the parent table. I am assuming that these tables have one-to-many FK relationships.
The following link could be helpful: http://msdn2.microsoft.com/en-us/library/bb332381.aspx
HTH
 
No comments:
Post a Comment