table Normalisation

wxdqz

New Member
lets supose that we have a huge table like this one
Table A
_____________________________
|song|filesizie|artist|album|
+----+---------+------+------

what is the SQL query that can split this table (Normalise)

so we get 4 tables like :

Table 1
__________________
IDsong|song|filesize|
------+----+--------+

where IDsong is the primary key of this table (auto incremented: 1,2,3,4....)

then
Table 2
________________
IDartist|artist|
--------+------+
where IDartist is the primary key of this table (auto incremented: 1,2,3,4....) and the column artist is the same that
in table A of corse without any repitition
cause in the fisrt table (table A) 2 or more song can have the same artist
In other words "artist" is the list of the artists.

then the same logic will be aplyed on "album"
on table 3

Finily
Table 4 that represent the relation between table 1 , 2 and 3

where ID is the primary key of this table (auto incremented: 1,2,3,4....)
___________________________
ID|IDsong|IDartist|IDalbum|
--+------+--------+-------+
Eg:

x 2 5 7
y 5 5 8

---------------------------
 
Back
Top