database - DB Design: What are benefit(s) of creating a table to hold all IDs of system entities? -
in simple data base design, entity tables have ids (mostly auto increment)
there system e.g. vtiger crm use master table store newly created ids.
question is:
- what benefits of described approach.
- what name of described approach, if any. mean designers call method?
moodle example of method too. example in moodle:
mdl_context has ids of other modules:
mdl_context - id - contextlevel - instanceid - path - depth
values - 115 - 50 - 17 - /1/84/90/115 - 4
instanceid id of other entity , contextlevel shows table, example 50 code course table.
without having mdl_context, mdl_course had it's own id, why `mdl_course exists?
you may think when database doesn't support auto increment columns , have implement auto incremental values yourself. or due limitations of specific implementation of auto increment in database, based on business rules, need customize auto increment module.
for example
when gaps in column values, important not happens.
consider selling scenario in witch need have exact sequence of numbers billing_ number column. using auto increment approach cause problems:
1- if bill, rejected lose number (rollback scenario)
2- in case of delete operation on billing table (if happens) lose number(delete scenario)
3- in distributed(clustered) db environments oracle rac (having multiple rdbms nodes) , using oracle sequences auto increment strategy, must use cache interval maintain integrity, again numbers lost.
in these cases may use metadata table crm_entity holding last used value per table on it(or other information if needed). locking metadata table inevitable, in heavy tps, there performance issue.
Comments
Post a Comment