我应该使用没有 GUID 的自然标识列吗? [英] Should I use Natural Identity Columns without GUID?

查看:53
本文介绍了我应该使用没有 GUID 的自然标识列吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以定义表主键和 2 个外键列的组合必须是唯一的吗?因此不添加新的 id 列(Guid 或 int)?

Is it ok to define tables primary key with 2 foreign key column that in combination must be unique? And thus not add a new id column (Guid or int)?

这有负面影响吗?

推荐答案

是的,完全没问题.为什么不?复合主键的缺点是它可能很长,并且从应用程序的角度可能更难唯一地标识单个行.但是,对于几个整数列(特别是在连接表中),这是一个很好的做法.

Yes, it's completely OK. Why not? The downside of composite primary keys is that it can be long and it might be harder to identify a single row uniquely from the application perspective. However, for a couple integer columns (specially in junction tables), it's a good practice.

这篇关于我应该使用没有 GUID 的自然标识列吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆