1
General Board / MySql Database Import
« on: October 03, 2006, 11:08:00 am »
I am becoming increasingly dissatisfied with EA's ability to import MySql database structures. It consistently drops datatypes (timestamp, mediumtext, unsigned int, undoubtably others), and loses foreign key constraints. Is there anything that can be done, on the user end, to improve this situation?
As an example, I created the following four tables and specified their relationships in EA, generated the ddl, created them in MySql, and then attempted to import those tables back into EA. The results were almost unrecognizable:
CREATE TABLE table3_table2_table1_rel
(
mId INT UNSIGNED NOT NULL AUTO_INCREMENT,
table3_id INT UNSIGNED NOT NULL,
table2_id INT UNSIGNED NOT NULL,
table1_id INT UNSIGNED NOT NULL,
client_ip INTEGER NOT NULL,
user_agent VARCHAR(255) NOT NULL,
ts_created TIMESTAMP NOT NULL,
PRIMARY KEY (mId),
KEY (table1_id),
KEY (table2_id),
KEY (table3_id)
)
;
CREATE TABLE table3
(
table3_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
flags TINYINT NOT NULL,
state TINYINT NOT NULL,
ts_created TIMESTAMP NOT NULL,
PRIMARY KEY (table3_id)
)
;
CREATE TABLE table2
(
table2_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
label VARCHAR(50) NOT NULL,
cdata TEXT NOT NULL,
ts_created TIMESTAMP NOT NULL,
PRIMARY KEY (table2_id)
)
;
CREATE TABLE table1
(
table1_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
flags TINYINT NOT NULL,
PRIMARY KEY (table1_id)
)
;
ALTER TABLE table3_table2_table1_rel ADD CONSTRAINT FK_table3_table2_table1_rel_table1
FOREIGN KEY (table1_id) REFERENCES table1 (table1_id)
;
ALTER TABLE table3_table2_table1_rel ADD CONSTRAINT FK_table3_table2_table1_rel_table2
FOREIGN KEY (table2_id) REFERENCES table2 (table2_id)
;
ALTER TABLE table3_table2_table1_rel ADD CONSTRAINT FK_table3_table2_Rel_table3
FOREIGN KEY (table3_id) REFERENCES table3 (table3_id)
;
As an example, I created the following four tables and specified their relationships in EA, generated the ddl, created them in MySql, and then attempted to import those tables back into EA. The results were almost unrecognizable:
CREATE TABLE table3_table2_table1_rel
(
mId INT UNSIGNED NOT NULL AUTO_INCREMENT,
table3_id INT UNSIGNED NOT NULL,
table2_id INT UNSIGNED NOT NULL,
table1_id INT UNSIGNED NOT NULL,
client_ip INTEGER NOT NULL,
user_agent VARCHAR(255) NOT NULL,
ts_created TIMESTAMP NOT NULL,
PRIMARY KEY (mId),
KEY (table1_id),
KEY (table2_id),
KEY (table3_id)
)
;
CREATE TABLE table3
(
table3_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
flags TINYINT NOT NULL,
state TINYINT NOT NULL,
ts_created TIMESTAMP NOT NULL,
PRIMARY KEY (table3_id)
)
;
CREATE TABLE table2
(
table2_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
label VARCHAR(50) NOT NULL,
cdata TEXT NOT NULL,
ts_created TIMESTAMP NOT NULL,
PRIMARY KEY (table2_id)
)
;
CREATE TABLE table1
(
table1_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
flags TINYINT NOT NULL,
PRIMARY KEY (table1_id)
)
;
ALTER TABLE table3_table2_table1_rel ADD CONSTRAINT FK_table3_table2_table1_rel_table1
FOREIGN KEY (table1_id) REFERENCES table1 (table1_id)
;
ALTER TABLE table3_table2_table1_rel ADD CONSTRAINT FK_table3_table2_table1_rel_table2
FOREIGN KEY (table2_id) REFERENCES table2 (table2_id)
;
ALTER TABLE table3_table2_table1_rel ADD CONSTRAINT FK_table3_table2_Rel_table3
FOREIGN KEY (table3_id) REFERENCES table3 (table3_id)
;