Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Software Design - Three-tier architecture

Layer 3 - Interface

Layer 2 - Business logic (get input from user, check if valid, send to database function)

Layer 1 - Database (creates, updates, gets records etc)


A user can add many contact phone numbers, if it is the first phone number added the system will automatically set that phone number to primary, and there after the user can change his primary phone number on his own.

When the first phone number record is created in the database, which layer is responsible to check if the phone number needs to be set to primary or not?

like image 694
001 Avatar asked Mar 06 '26 17:03

001


2 Answers

Business layer. The database should be storing data, not making decisions. The interface just interacts with the user. The business layer makes the rules.

like image 70
richard Avatar answered Mar 08 '26 07:03

richard


Your business logic should handle it when the phone number gets added to the user. You can verify it works by providing unit/integration tests for it.

like image 45
Dan Avatar answered Mar 08 '26 06:03

Dan