Question

I have a table of users, students and teachers. For example I want to create a new student and assign him a user account from the list. This works for me, but it is possible to assign the same user account to more students. How to fix this? Thank you.

Was it helpful?

Solution

you should add unique index in students table, user_id field, this not allow to repeat, the same user_id, in students table.

http://dev.mysql.com/doc/refman/5.0/es/create-index.html.

You should use, "UNIQUE".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top