Normalleştirilmiş bir şekilde bir veritabanına ayrıştırmak istediğim bir xml dosyasına sahibim. İkinci tablo bir-çok ilişki tablosunu oluşturmak için edindiğim fikir. İsim, başlık her dosya grubu için asla değişmeyecek, ancak indirme yolları farklı olacaktır.
tablo 1
id | name | title | download_path
----------------------------------------------------------------------
1 | FileGroup 1 | This is the first file group | /this/1/1.zip
2 | FileGroup 1 | This is the first file group | /this/1/2.zip
3 | FileGroup 2 | This is the second file group | /this/2/1.zip
4 | FileGroup 2 | This is the second file group | /this/2/2.zip
5 | FileGroup 3 | This is the third file group | /this/3/1.zip
XML Dosyası
-
File Group 1
<title>This is the first file group</title>
/this/1/1.zip
-
File Group 1
<title>This is the first file group</title>
/this/1/2.zip
-
File Group 2
<title>This is the second file group</title>
/this/2/1.zip
-
File Group 2
<title>This is the second file group</title>
/this/2/2.zip
-
File Group 3
<title>This is the third file group</title>
/this/3/1.zip
Tablo 2
group_id | file_id
-----------------------------
1 | 1
1 | 2
2 | 3
2 | 4
3 | 5
What is the best way to do this when parsing through the XML. If i put the xml data into an array and foreach through each item, i need to be able to able to group them on the fly and create the relationship in Tablo 2. I did have the idea of just creating tablo 1 and then afterwards building the relationship table, but even then then i dont know how best to group them. I have nothing in the xml to say they are grouped other that name and title. Each group can have any number of file download paths.
I do not have any say on the xml Dosyası creation. Its all I have to deal with.