Imdabaum
01-22-2010, 10:12 AM
I have an application where I create a record anytime someone submits a request form. I enter the data from the request form and the application calculates what the salesman should be paid.
If this salesman has a manager then the application automatically creates a new record for the manager.
TABLE1
ID
SalesmanID
INVOICE1
INVOICE2
CUSTID
Plan_Type_CD
Monthly_Payment
ManagerID
EarnedAs
MGR_RecID
Notes
Currently I am relating the MGR_RecID to the Table1 ID field. I have seen this done, but I don't know if it's the best practice. ie having a field in a table related to a field in the same table.
But the join interprets this as the MGR_RecID having a one-to-many relationship with the other records, when in fact For each ID there can only be at most 1 MGR_RecID created.
So if I create the first record (ID=1) the manager's record is submitted as well (ID=2-or next availble ID). In the record where ID=1, the MGR_RecID =2.
The inserts work without even having the MGR_RecID field. But deleting is another story because without the relationship, there's no way to delete both records without adding more code. Essentially, I want to cascade delete to the Manager's record if the employee's record is deleted.
If this salesman has a manager then the application automatically creates a new record for the manager.
TABLE1
ID
SalesmanID
INVOICE1
INVOICE2
CUSTID
Plan_Type_CD
Monthly_Payment
ManagerID
EarnedAs
MGR_RecID
Notes
Currently I am relating the MGR_RecID to the Table1 ID field. I have seen this done, but I don't know if it's the best practice. ie having a field in a table related to a field in the same table.
But the join interprets this as the MGR_RecID having a one-to-many relationship with the other records, when in fact For each ID there can only be at most 1 MGR_RecID created.
So if I create the first record (ID=1) the manager's record is submitted as well (ID=2-or next availble ID). In the record where ID=1, the MGR_RecID =2.
The inserts work without even having the MGR_RecID field. But deleting is another story because without the relationship, there's no way to delete both records without adding more code. Essentially, I want to cascade delete to the Manager's record if the employee's record is deleted.