Hi,
First i appologized if my questions are too basic, but i’ve tried out for quite long without getting the answer…
I’ve tried to create an ER diagram through both ways
(1) reverse engineering from DDL script
(2) manually
For both ways, i faced one same question.
When i create a relationship, the PK in my parent_table appeared as PFK in my child_table as a new attribute.
I already created the key in my child_table so i do not want it.
My parent_tableCREATE TABLE DefaultDatabase.parent_tb
(
PARENT_ID Bigint UNSIGNED NOT NULL AUTO_INCREMENT,
INSERT_DATE Datetime NOT NULL,
UPDATE_DATE Datetime,
PRIMARY KEY (PARENT_ID)
) ENGINE = InnoDB;
My child_tableCREATE TABLE DefaultDatabase.child_tb
(
PARENT_ID Bigint UNSIGNED NOT NULL,
CHILD_ID Varchar(20) NOT NULL,
POST_TYPE_ID Tinyint UNSIGNED NOT NULL,
INSERT_DATE Datetime NOT NULL
) ENGINE = InnoDB;
ALTER TABLE DefaultDatabase.child_tb ADD PRIMARY KEY (PARENT_ID,CHILD_ID,POST_TYPE_ID)
When i create ER diagram through the reverse engineering, it appears like this.
**parent_tb
**---------------
parent_id(PK)
insert_date
update_date
child_tb---------------
parent_id(PK)
child_id(PK)
post_type_id(PK)
It is no problem at this stage.
BUT when i join the relationship, it appears like this in the child_tb
parent_id(PK)
child_id(PK)
post_type_id(PK)
parent_id(PFK) <----this was added--------------
Maybe my way to craete the ER diagram is wrong…
How to make the original parent_id(PK) to parent_id(PFK) without adding another individual elements to it?
Thank you.