Database ERD design: 2 types user in one table

database

I have read this (Database design: 3 types of users, separate or one table?)

I decided to put admin and normal user in one table since the attributes are similar:

fullname,
address,
phone,
email,
gender
...

Then I want to draw ERD, suddenly my mind pop out a question. How to draw?
Customer make appointment and admin approve appointment. now only two tables, and admin, customer in same table. Help.

Best Answer

That's what I'd do:

table user (
  id primary key,
  name,
  email,
  -- etc
);

table approver (
  id primary key foreign key user(id),
  appointed_date, 
  -- etc
);

table appointment (
  -- whatever PK
  created_by foreign key user(id), 
  approved_by foreign key approver(id),
  -- etc
);

Now any user can create an appointment, but only users also present in approver table can approve it.

Related Topic