首页 > 解决方案 > 如何对复合主键进行约束,使其属性总是彼此不同?

问题描述

我有一个具有以下属性的复合主键:(departure_airport,arrival_airport),我想知道是否有某种约束来确保离开机场与到达机场不同?

标签: database-design

解决方案


Being a composite key is irrelevant.

You need to apply a CHECK constraint or write a trigger that compares the two fields for equality.


推荐阅读