I have a problem with assigning a primary key in one of the tables containing employee info. There is no unique column in that table, The only option I am left with is taking combination of three columns as a primary key.
-
But it gives a warning message as
Warning! The maximum key length is 900 bytes. The index 'pk_hrempid' has maximum length of 1530 bytes.For some combination of large values, the insert/update operation will failI came to know that this would be a major problem in the future for inserting the data. Is there a solution for this warning? -
Other question is can I put an auto-increment value as a unique id, is it recommended? I want to make sure that it does not give problems in the future as I have many tables containing employee info from the other departments. Some employees may be present in two or more tables
Any help is appreciated!
Whilst is it sounds from your attempt at a compound primary key that you’re attempting the best-practice of using a “natural key”, there’s nothing ‘wrong’ with using an auto-incrementing
IDfield.If your suggested fields are too large to be used as a key, perhaps they weren’t the best choice in the first place. Could you add another “natural” key column with a better datatype perhaps?
Don’t forget to take into account the optimizations that are possible by choosing good indexes and suitable datatypes for tables that are going to be heavily-queried.