Rivka
Rivka

Reputation: 2202

DB Design for Admins & Customers

I'm creating a site who's users will include customers and different levels of Admins. What is the recommended practice or what would be the correct way of setting up the DB Tables for this?

Both Customers and Admins will have a username and password. Customers, though, will also have a CustomerCode and Location, and Admins will have different levels/roles.

Should they be separate objects? If yes, how should I be relating the two?

Thank you for any input.

Upvotes: 2

Views: 802

Answers (1)

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 726579

There are three major ways of dealing with mapping logical requirements like yours to DB tables - (1) using a single table for both users and admins, (2) using two separate tables, and (3) using three tables, one containing the common data among the two categories of users.

The first and the third ways are good for cases when customers and admins should sometimes be used interchangeably; the second way is better when it is not a concern. I prefer the #3, because it's the most normalized way of modeling the two kinds of users.

Upvotes: 1

Related Questions