1

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

2 Answers 2

2

here is command:

    LOAD DATA INFILE 'c:/country.csv' 
    INTO TABLE *table_name*
    FIELDS TERMINATED BY ',' 
    ENCLOSED BY '"'
    LINES TERMINATED BY '\n'
    IGNORE 1 ROWS

Keep one thing in mind, never appear , in second column, otherwise your import will stop

Sign up to request clarification or add additional context in comments.

1 Comment

i know how to do that. But i don't know how to convert between the input data and desired structure. please see my example
0

Selamat malam.

You must import these data from one by one table which include a Primary key, then import data from tables which include a Foreign key

Except you want a backup/restore database, you must import all table of database.

4 Comments

can you explain the detail? the problem here is because the different structure between input data (csv) and mysql table. And i need to import the data from csv to avoid input manual one by one
Oh i understand now, so it is about the begining. What sistem you use (phpmyadmin, SQL Server Management Studio)?
I use phpmyadmin. the difference is the structure table not the file itself (SQL and CSV). Please read my question in detail
Well, i told you to import a data from table with foreign key included.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.