database-design - 如何对复合主键进行约束,使其属性总是彼此不同?
问题描述
我有一个具有以下属性的复合主键:(departure_airport,arrival_airport),我想知道是否有某种约束来确保离开机场与到达机场不同?
解决方案
Being a composite key is irrelevant.
You need to apply a CHECK
constraint or write a trigger that compares the two fields for equality.
推荐阅读
- sql - SQL Server Varchar 军事日期格式 YYYY-MM-DD
- javascript - 将 N 个正奇数相乘
- java - HIbernate 不会创建另一个数据库中已经存在的表
- c# - 尝试从 JSON 对象中获取值会冻结任务
- ruby-on-rails - 带有 ActiveAdmin 的 text_field_tag
- html - 为什么不(点击)将我的数据发送到里面
- python - Apache Ignite 插入速度极慢
- conv-neural-network - 如何训练一个 CNN 模型?
- javascript - 如何使用 Node.js mongodb 官方提供程序重新创建 mongo 数据库?
- php - 遍历复杂的 json 数组