Hey guys, I need some advice on the best way to set this up. The project is being done in mysql and php. It's a really simple question, but I can't decide.
I need to have a user system where employees and customers can log in. Both groups need to have different restrictions based on what they can do / view on the site. Each customer will also be able to set up "sub-customers", their employees, with access to anything in which they (the "top-level" customer) are currently granted access. Also, unlike employees, customers will only be able to access files directly related to that customer.
I was considering a mysql database setup something like this:
PHP Code:
[employee.table]
employee-id
employee-name
etc...
## Example Data
1, Brenda Jones, ...
[customer.table]
customer-id
customer-company
customer-code
## Example Data
1, Widgets R Us, C001
2, Widgets Co, D005
[user.table]
user-id
user-name
user-pass
user-type
user-restriction
## Example Data
1, John Smith, ***, customer, C001
2, Brenda Jones, ***, employee, ''
[userperm.table]
user-id
program
perm
## Example Data
1, users, edit
2, user, view
Of course, this isn't the exact way, just a rough idea. I know I'll need some way to link employees in the user table to the employ table.
I'm trying to keep it simple, avoid data redundancy, etc...
I don't know what the best way to accomplish this would be, even considered two seperate user tables (customer-users and employee-users.) Another requirement is that any action done needs to be associated with the user that did it (e.g. if a user is added, who did it?)
Any ideas? Thank you.