Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is DAO responsible for inserting records into 'join' table

For example, if I have two tables: Customer and Product and I need to map customers to products (many-to-many). So I need a third (join) table, which will contain CustomerId and ProductId. Is DAO responsible for inserting records into the third (join) table?

P.S. For now I have CustomerDAO and ProductDAO. Mapping customers to products handled by a service-layer.

like image 527
WelcomeTo Avatar asked Oct 06 '22 03:10

WelcomeTo


2 Answers

Yes, your DAO can implement methods like

  • updateProduct(CustomerId)
  • updateCustomer(ProductId)
  • findCustomerByProduct(productId)
  • findProductsByCustomer(customerId)
like image 178
TheWhiteRabbit Avatar answered Oct 07 '22 17:10

TheWhiteRabbit


Yes of course, it is its responsibility. If not DAO, then who will do it instead of it?

like image 35
Andremoniy Avatar answered Oct 07 '22 16:10

Andremoniy