user372834
user372834

Reputation: 157

How to make every ID in a database unique

I have 3 tables called Teachers, Admin and Students and they all have an ID. How do I make it so that none of their IDs are the same.

Upvotes: 0

Views: 48

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521249

As mentioned by @Ron in his comment, perhaps the easiest option here would be to just use a single users table with a role column, something like this:

id | role
1  | teacher
2  | student
3  | student
4  | admin

However, it is also fairly straightforward for you to continue using three separate tables for the teachers, students, and admins. You can logically make their IDs unique by just appending a prefix to each number, e.g. A123 is the 123rd admin, while S46 is the 46th student.

Upvotes: 1

Related Questions