php - CakePHP Database Structure Multiple Relationships -
in simple system there users table user logins , passwords stored customers table.
users can related customers in 3 different ways. 1) sales representative customer 2) lead generated customer 3) customer account entered rep
originally planned on having on customers table: customers.user_id customers.lead_id customers.entered_by_id.
with cakephp wrong way? how should designed? 1 day new cakephp.
without knowing more building , requirements, do:
users
: contains just authentication infousers.role
: useful querying role specific user (customer, sales rep, admin, etc.)users.username
users.password
sales_representatives
: contains sales rep datasales_representatives.user_id
: links sales rep data specific user
customers
: contains customer datacustomers.user_id
: links user specific user (assuming want them log in, if not can skip this)customers.sales_representative_id
: links customer sales rep. might want store history of sales reps specific customer in separate table, field current sales rep.customers.lead_id
: links specific lead customer came from. can null in case inbound , not lead, link useful.
leads
: contains lead dataleads.sales_representative_id
: contains current sales rep given lead. customers table, might want store list of historical sales reps given lead in separate table.
you might optionally add user_id
lead table if lead can login, might not case in system.
what entered_by_id
? seems more lead-related id, in case may want track in leads table (separate sales_representative_id
).
most of stuff isn't cakephp-related, though schema planning go long way making using cakephp easy :)
Comments
Post a Comment