If you demonstrated to your professor that assigning a unique arbitrary integer to each user is important for your application, then, of course, he is mistaken in stating that he is "absolutely useless and not needed."
However, you may have missed his point. If he told you that the requirement is that โnone of the two users can have the same usernameโ, then you have not fulfilled this requirement.
Sincere thanks for submitting your SQL DDL, this is very useful, but most do not worry about SO.
Using your table, I can do this:
INSERT INTO users (username) VALUES (NULL); INSERT INTO users (username) VALUES (NULL); INSERT INTO users (username) VALUES (NULL); INSERT INTO users (username) VALUES (NULL); INSERT INTO users (username) VALUES (NULL);
The result is the following:
SELECT uid, username, passhash, email, rdate FROM users; uid username passhash email rdate 1 <NULL> <NULL> <NULL> <NULL> 2 <NULL> <NULL> <NULL> <NULL> 3 <NULL> <NULL> <NULL> <NULL> 4 <NULL> <NULL> <NULL> <NULL>
I think this is what your professor tried to do: without observing the natural username key, you really have no data integrity.
If I were a professor, I would also highly recommend deleting nullable columns from your design.
onedaywhen Nov 05 '10 at 12:06
source share