views:

57

answers:

2

Hi, I would like to know how to backup my data from 2 separate tables (CATEGORIES and SUBCATEGORIES, where SUBCATEGORIES belong to a CATEGORY) in such a way that I can restore the relationship at a later time. I am not sure if mysqldump --opt db_name would suffice.

Example:

Categories:

| ID | name
-----------
| 1  | Audio
| 9  | Video

Subcategories:

| ID | category_id | name
-------------------------
| 1  | 1           | Guitar
| 2  | 1           | Piano
| 3  | 9           | Video Camera

Thanks

+1  A: 

the mysqldump default add the create table command and it save the relation.

Haim Evgi
+4  A: 

mysqldump is sufficient

It will generate the SQL code necessary to rebuild your database and as the relationships are not special data (just logical coincidences between tables) it's enough to backup a database. Even by using mysqldump without the --opt param it will add indexes definitions so the contraints will remain

victor hugo