Primary Keys in Oracle and SQL Server

后端 未结 4 1332
别跟我提以往
别跟我提以往 2021-01-21 16:24

What\'s the best practice for handling primary keys using an ORM over Oracle or SQL Server?

Oracle - Should I use a sequence and a trigger or let the OR

4条回答
  •  一整个雨季
    2021-01-21 17:04

    Sometimes, there is a natural, unique identifier for a table. For instance, each row in a User table can be uniquely identified by the UserName column. In that case, it may be best to use UserName as the primary key.

    Also, consider tables used to form a many to many relationship. A UserGroupMembership table will contain UserId and GroupId columns, which should be the primary key, as the combination uniquely identifies the fact that a particular user is a member of a particular group.

提交回复
热议问题