Hello everyone.
I was confused on what makes a many-to-one relationship. For instance I modeled this .ddl db2 code in Rational Software Architect and its showing its a many to 1 relationship based on the code I'm going to paste.
The reason Im' asking this is because I'm writing a program and I need to show a many to one relationship so when I model the code it will also appear.
Here is the .ddl:
Now here is the image that is produced from that code:Code:CREATE TABLE NODE_OBJ ( HOSTNAME VARCHAR(250), MGMT_IPADDR VARCHAR(60), NETVIEW_ID CHAR(32), NODE_ID CHAR(32) NOT NULL, OBJ_ID DECIMAL(20 , 0), SELECTION_NAME VARCHAR(120), STATUS INTEGER, TCPIP_JOB_NAME VARCHAR(25), SYSPLEX_NAME VARCHAR(25), SYSTEM_NAME VARCHAR(25), IS_MANAGED INTEGER, USER_CREATED INTEGER, IS_DELETED TIMESTAMP, IS_DHCP CHAR(1) ) DATA CAPTURE NONE ; CREATE TABLE ITM_SERVICES ( NODE_ID CHAR(32) NOT NULL, SVC_NAME VARCHAR(120) NOT NULL ) DATA CAPTURE NONE ; ALTER TABLE NODE_OBJ ADD CONSTRAINT PK_NODE_OBJ PRIMARY KEY (NODE_ID); ALTER TABLE ITM_SERVICES ADD CONSTRAINT PK_ITM_SERVICES PRIMARY KEY (NODE_ID, SVC_NAME); ALTER TABLE NODE_OBJ ADD CONSTRAINT NODE_OBJ_NETVIEW_ID_MAP_FK FOREIGN KEY (HOSTNAME) REFERENCES NETVIEW_ID_MAP (HOSTNAME) NOT ENFORCED; ALTER TABLE ITM_SERVICES ADD CONSTRAINT ITM_SERVICES_NODE_OBJ_FK FOREIGN KEY (NODE_ID) REFERENCES NODE_OBJ (NODE_ID) NOT ENFORCED;
http://img225.imageshack.us/img225/6104/relzz9.jpg
As you can see its showing:
NODE_OBJ is having a 1 to many relationship on the table: ITM_SERVICES
But through script, what makes somthing a 1 to 1 relationship, a 1 to many relationship or a many to many relationship?
I see that NODE_OBJ's primary key is NODE_ID and I also see that ITM_SERVICES is using NODE_ID as its foriegn key, so there is a relationship, but what is making that relationship a many?
Thanks for the help!![]()
Note: I'm using DB2 v8.2





Reply With Quote