php - Several entities having a one to many relation with one specific entity -
imagine scenario have companies, bank accounts, , customers. both companies , customers can have many bank accounts bank account can belong either 1 customer or 1 company. i'd know best way design such database not involve complicated queries or business logic when comes point need delete bank account database.
one solution i've seen reference id's of bank accounts json string array on either companies or customers this:
in customer or company ====================== id name bank_account 1 bob [2,3,4,5]
it's not bad solution i'm wondering if there's better way this.
nb: i'm building application using symfony 2.7.5 , therefore using doctrine orm library.
one way handle have both companies , customers inherit common ancestor, users (take @ doctrine inheritance). there 1 many relationship between users , bank accounts, easy implement , take care of dependencies.
Comments
Post a Comment