Hello All,
I am designing a database for my
Java web application. I am struck in establishing relationships between tables.
Example database tables are given below
TABLE1
ID
GID
ATTR
TABLE2
ID (PKEY)
ATTR1
GID of Table1
TABLE3
ID (PKEY)
ATTR
GID of Table1
Table1 has composite primary key(ID,GID). Table1 ID is unique. Table1 GID is used to group different rows of Table1 and this GID can be mapped either to Table2 row or Table3 row but not both (one to one mapping)
When Table2 or Table3 row is deleted then associated GID entries from Table1 should be deleted. This is not mandatory.
How can i relate Table2 and Table3 to Table1. Please suggest me if we can represent data in other better way.
Any help on this is highly appreciated.
Thanks,
Venkat