Thanks for the reply, Emmanuel. I got that. But take the case of an entity which has more than one OneToOne relations. Let's say, Employee which is related to Address, Project and Location. Now, the employee table will look something like ...
TABLE TST_EMPLOYEE (
CMP_COD VARCHAR2 (6) NOT NULL,
EMP_ID VARCHAR2 (6) NOT NULL,
EMP_NAM VARCHAR2 (30) NOT NULL,
ADDRESS_CMP_COD VARCHAR2 (6),
ADDRESS_ID VARCHAR2 (6),
PROJ_CMP_COD VARCHAR2 (6),
PROJ_ID VARCHAR2 (6),
LOC_CMP_COD VARCHAR2 (6),
LOC_ID VARCHAR2 (6),
CONSTRAINT PK_TST_EMPLOYEE
PRIMARY KEY ( EMP_ID, CMP_COD )
)
But the content of the columns CMP_COD, ADDRESS_CMP_COD, PROJ_CMP_COD and LOC_CMP_COD will all be the same and redundant if the data in the table is consistent.
I get your point that someone could set wrong data (like address with wrong company code) into the entity if we share all the CMP_CODs. But can't we check this at runtime in this case by introducing an additional condition into the WHERE clause of the query which checks whether the CMP_CODs are actually the same like ....
UPDATE TST_EMPLOYEE SET ADDRESS_ID =
(
SELECT A.ADDRESS_ID
FROM TST_UNI_ADDRESS A, TST_UNI_EMPLOYEE B
WHERE A.ADDRESS_ID = ?
AND A.ALN_COD = B.ALN_COD
)
or something like this.
I ask this because I guess this will be a problem common to all huge systems which need to be multi-hosted and need data partitioning. And replication of the IDs will take quite a bit of disk space when the number of rows in the table increases.
It will be nice if I could get your views on this.
Thanks,
Dilip.
|