I am building an expert system with naive bayes method. I have a few table : rule, choice and diagnosis Rule:
-----------------------------------
|id|id_rule|id_diagnosis|id_choice|
-----------------------------------
|1 | 1| 1| 1|
|2 | 1| 2| 3|
|3 | 1| 3| 5|
|4 | 1| 4| 7|
|5 | 2| 1| 2|
|6 | 2| 2| 4|
|7 | 2| 3| 6|
|8 | 2| 4| 7|
-----------------------------------
Diagnosis
------------------------
|id_diagnosis|diagnosis|
------------------------
| 1| AAA|
| 2| BBB|
| 3| CCC|
| 4| DDD|
------------------------
Choice
-------------------------------
|id_choice|id_diagnosis|choice|
-------------------------------
| 1| 1| aa|
| 2| 1| bb|
| 3| 2| cc|
| 4| 2| dd|
| 5| 3| ee|
| 6| 3| ff|
| 7| 4| gg|
| 8| 4| hh|
-------------------------------
Within user interface, I can manually input the parameter (add rule) using select option form. With the name of option is id_choice and id_diagnosis. But I have many data that I need to calculate to this system. I have the data in csv format, the same format as the output of rule list ini my system like this:
----------------------
|rule|AAA|BBB|CCC|DDD|
----------------------
|1 |aa |cc |ee |gg |
|2 |bb |dd |ff |gg |
----------------------
But the problem is, I don't know how to add the data from csv format to database since in the table rule it only record the id, not the name of choice and diagnosis itself. I know that we can convert csv to multidimensional arrat, but I still confuse how to convert from name to id without doing it manually. Thanks