MajP
You've got your good things, and you've got mine.
- Local time
- Yesterday, 23:30
- Joined
- May 21, 2018
- Messages
- 8,904
You do not do this manually. It is done via code to ensure it is correct. The code counts the number of supervisors in the chain. This way if any agent is added or removed the levels will automatically update.but it seems i cannot set the "agent level" field", just cannot wirte in..and it i not even automatically set (as it looks like should be, being impossibile to write in that field
In real life with lots of branches and levels it would be near impossible to do this manually. So this is much safer, faster, and more accurate to update in code.
I did not add a relationship diagram to this database, but I should. You can enforce referential integrity, which means every child must report to another record in the database. Assume you haveMay happen that an agent leave
In this case that part of royalties would go to MAIN AGENCY
How can we mange this?
-Main
--A
----B
--------C
----D
----E
Assume Employee B leaves. If Referential Integrity is established then you cannot delete B since it has a child C. You need to first reassign C. I would assume C gets reassigned to A becoming a second level not to Main. You would choose a new "reports to" for C and then delete B. I would assume C gets reassigned to A becoming a second level not to Main.
But if you are suggesting that if B leaves C is still considered a 3rd level without a 2nd level supervisor then that cannot be done. This structure does not support where C is considered 3rd level but does not have a 2nd level supervisior.
-Main
--A (lvl 1)
--------C (lvl 3)
----D
----E
Normally there is no reason to look at a PK. It is only used to relate records. Main is 9 because I added it after all the other records. The levels are calculated in code and has no relation to the PK. When you assign a record A to Main you go to the combo box and pick "Main". In the background it stores the key 9 in A's report to. All you see is reports to "Main", but in fact 9 is stored in the table.In the ADD EMPLOYEE table the agent pk for MAIN AGENCY is 9
In ROYALTIES ASSIGNEMENT the RECEIVING AGENT LEVEL for MAIn AGENCY is 0..