I have an SQL table with basically the following structure:
PK (int, primary key), userID (int), data (varchar 64)
In principle, any user-defined userID can store any number of short lines. However, no user is allowed to store two identical lines (although user 1 and user 2 can store the same line separately). I would, if at all possible, would like to implement this restriction at the database level, because IMHO structural restrictions should always be in tables , as well as in programs that insert / read data from tables.
The only thing I can think of is to add a third column, in which I combine the user ID and data with each insert and call the that column, but this seems too hacked for me. I am open to a complete restructuring of my tables if one of you guys has a better way to do this, which will allow me to set this field limit :)
Thanks!
Mala
sql unique structure
Mala
source share