It depends on your data design and the way you access the data in the table.
Typically, the log table does not need a primary key, because you often access the logs in groups and do not delete / edit individual messages (you can clear the entire table or log time window).
In other cases, the identifier field may be redundant. If customers subscribe to your site using OpenID (or just an email address), you already have your primary key. However, in this case, it is recommended to add an excess ID field, because the integer uses less space than the lines, and you must repeat the identifier in all respects in which the entity participates!
Finally, relationship tables do not need an explicit identifier in 99% of cases. Example: Many-to-many relationship between users and groups. The relationship table consists only of the user ID and the group ID , which is your main key (you would like to index two fields separately for performance ...).
By the way, an auto-incrementing identifier does not slow performance. The counter value is stored in the table metadata, so when the DBMS inserts, it automatically increases the reference counter, and this can be done using the equivalent Java AtomicInteger and C # Interlocked , so you donβt have to worry about it at all!
usr-local-ΞΞ¨ΞΞΞΞ©Ξ
source share