php - Mysql - Many tables to come up with only 1 table for Login purposes -


example tables:

employee, customer , contractor

contractor table works same way employee , customer different field exclusive table

purpose: create user table base logging-in.

proposed user table

user_id     password     user_type           -------------------------------------------------------------------- employee1    123*89       employee        employee2    0123         employee         customer1    12378        customer        customer2    1234         customer        contractor1  45678        contractor       

employee table:

id          firstname   lastname   address -------------------------------------------------------------------- employee1    bon        smith       123 north street ny employee2    john       doe         245 south street ny 

customer table:

id          firstname   lastname   address -------------------------------------------------------------------- customer1    ron        price       123 north street ny customer2    peter      doe         245 south street ny 

questions:

  • is user table correct?
  • should put password field every table (employee, customer , contractor) rather placing on user table?
  • is there best way implement user table know?

clarification: want put data id different tables(employee, customer , contractor) 1 table user.

my suggestion

table user role

------------------------ id   |    rolename     |  1   |    employee  2   |    contractor   | ------------------------ 

table useraccount

------------------------------- id username  password userrole | ------------------------------- 1  employee1  password    1    | 2  contractor password    2    | -------------------------------- 

table employee

-------------------------------------------- id firstname  lastname  address  useraccount| --------------------------------------------| 1   fname      lname    address     1       | 2   fname      lname    address     2       | -------------------------------------------- 

table contractor

-------------------------------------------- id firstname  lastname  address  useraccount| --------------------------------------------| 1   fname      lname    address     1       | 2   fname      lname    address     2       | -------------------------------------------- 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -