I read many articles about DDD and noticed that most of them use the GUID as their identifier when saving the database. The GUID is said to scale well, and automatically increasing the ID is a big no-no when it comes to scalability.
Now I am confused whether to use a GUID or auto-increment .
Basically, the domain is membership system (binary tree). (tracking of register members) membership system (binary tree). (tracking of register members)
The first requirement is that we must have something that uniquely identifies them in the system (we call it Account No. ), possibly 7digit.
The new Members can then be registered with another Member . We call it a referral.
Now what I plan to do is to have a MemberId type GUID as the DomainObject identifier, where it serves as the primary key that will be used for connections, foreign keys (on Referral, referer_id will be the GUID of MemberId ). AccountNo will be a column with automatic promotion or can be obtained from the repository using MAX () + 1. It will be mainly used for search functions in the system and in links.
Should the DomainObject object identifier remain hidden to users of the system since it was just technically implemented?
Is it possible to combine both? GUID as row_id in the database (Surrogate key). and Auto-Increment for (Natural Key)?
Is it possible to exclude AccountNo from the constructor, because it will automatically increase? How about the need to use invariants? So, does the next identifier from the repository get the path and include AccountNo in the constructor?
Should I just use the Auto-Increment ID and forget about the GUID, delete MemberId and let AccountNo be the identifier of the DomainObject?
Note:
I am not creating the next facebook.
I just want to practice the Tactical side of DDD to learn how to make tough architectural decisions, knowing their PROS and CONS.
I just want to practice the strategic side of DDD to learn how to make tough architectural decisions, knowing their PROS and CONS and their implementation.
If we make 3 scenarios with registration of the participant:
- The first scenario: registration of participants occurs every minute.
- Second scenario: registration of participants occurs every hour.
- Scenario Three: Registration of participants takes a maximum of 5 days.
How will this affect decisions?
Technological stack:
- ASP MVC 5
- Sql Server 2014
- FROM#
- Dapper ORM