Hi I would like to ask when should I use Pivot table? My colleague are discussing why should we use pivot table instead of directly adding the relationship to another table below is a sample of a direct approach and I'm not sure if this is better than using a pivot table.
This is a one-many relationship. A branch can have many store
Table1: Branch
Field:[
id
name
address
]
Table2: Store
Field: [
id
branch_id **[foreign_key related to branch table]**
name
fee
location
type
]
So I was thinking is it better to use the above structure or use the below approach which makes use of a pivot table
Table1: Branch
Field:[
id
name
address
]
Table2: Store
Field: [
id
name
fee
location
type
]
Table3: Branch Store
Field: [
id
branch_id **[foreign key related to branch table]**
store_id **[foreign key related to store table]**
]
Our main concern is the query speed for this as the second approach will need to make use of another(third) table just to retrieve or relate the two tables. But the first approach will only make use of two table