Hello everyone,

I'm confused on this part of the SQL code of the connects table below:
Code:
CONSTRAINT `connects_entity_fk1` FOREIGN KEY (`aEndEntityId`) REFERENCES `entity` (`entityId`) ON DELETE CASCADE, 
  CONSTRAINT `connects_entity_fk2` FOREIGN KEY (`zEndEntityId`) REFERENCES `entity` (`entityId`) ON DELETE CASCADE
Code:
DROP TABLE IF EXISTS `connects`; 
CREATE TABLE `connects` ( 
  `connectionId` int(11) NOT NULL auto_increment, 
  `aEndEntityId` int(11) NOT NULL, 
  `zEndEntityId` int(11) NOT NULL, 
  `unidirectional` int(11) NOT NULL, 
  PRIMARY KEY  (`connectionId`), 
  UNIQUE KEY `connects_uk` (`aEndEntityId`,`zEndEntityId`,`unidirectional`), 
  KEY `connEntityA_idx` (`aEndEntityId`,`zEndEntityId`,`connectionId`), 
  KEY `connEntityZ_idx` (`zEndEntityId`,`aEndEntityId`,`connectionId`), 
  CONSTRAINT `connects_entity_fk1` FOREIGN KEY (`aEndEntityId`) REFERENCES `entity` (`entityId`) ON DELETE CASCADE, 
  CONSTRAINT `connects_entity_fk2` FOREIGN KEY (`zEndEntityId`) REFERENCES `entity` (`entityId`) ON DELETE CASCADE 
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
Here is the 'entity' table:
Code:
CREATE TABLE `entity` ( 
  `entityId` int(11) NOT NULL, 
  `mainNodeEntityId` int(11) default NULL, 
  `entityName` varchar(255) collate utf8_bin NOT NULL, 
  `domainMgrId` int(11) NOT NULL, 
  `entityType` int(11) NOT NULL, 
  `createTime` datetime NOT NULL, 
  `changeTime` datetime NOT NULL, 
  `displayLabel` varchar(255) collate utf8_bin NOT NULL, 
  `description` varchar(512) collate utf8_bin default NULL, 
  `alias` varchar(255) collate utf8_bin default NULL, 
  PRIMARY KEY  (`entityId`), 
  UNIQUE KEY `entity_uk` (`domainMgrId`,`entityName`), 
  KEY `entityMainNode_idx` (`mainNodeEntityId`,`entityId`), 
  KEY `entityEntityType_idx` (`entityType`), 
  KEY `entityName_idx` (`entityName`), 
  KEY `entityDomain_idx` (`domainMgrId`), 
  CONSTRAINT `entity_domainMgr_fk` FOREIGN KEY (`domainMgrId`) REFERENCES `domainMgr` (`domainMgrId`) ON DELETE CASCADE, 
  CONSTRAINT `entity_entityType_fk` FOREIGN KEY (`entityType`) REFERENCES `entityType` (`entityType`) ON DELETE CASCADE, 
  CONSTRAINT `entity_entity_fk` FOREIGN KEY (`mainNodeEntityId`) REFERENCES `entity` (`entityId`) ON DELETE CASCADE, 
  CONSTRAINT `entity_entiytNameCache_fk` FOREIGN KEY (`entityId`) REFERENCES `entityNameCache` (`entityId`) ON DELETE CASCADE 
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
When you insert a value into the entity table,
entityID is the primary key, but what does it mean when connects table uses:
CONSTRAINT `connects_entity_fk1` FOREIGN KEY (`aEndEntityId`) REFERENCES `entity` (`entityId`) ON DELETE CASCADE,
CONSTRAINT `connects_entity_fk2` FOREIGN KEY (`zEndEntityId`) REFERENCES `entity` (`entityId`) ON DELETE CASCADE

I searched the connects table and NO entity ID is in the table that corresponds to the entity ID in the entity table;

For instance, if there is a value in the entity table, entityId = 95. If I search the connects table there is no "95" value anywhere. But it says, aEndEntityId and zEndEntityId are references to entityId, so who is referencing the value 95?


Thanks any help would be great!!

PS: I used mysql work bench to see the relationship, and it says connects table is connected some how to the entity table, but I don't see why when I search for the values I see no relationship of entityId and what is referncing it in the connects table.