可以跨表创建唯一索引,基本上使用视图和唯一索引。 虽然我有一个问题。 给出两个(或三个)表格。 Company
- Id
- Name
Brand
- Id
- CompanyId
- Name
- Code
Product
- Id
- BrandId
- Name
- Code
我想确保唯一性的组合: Company/Brand.Code
和 Company
我有以下SQL: select * from
(
select p.ID,
Received = (select Rec from Exp
where EstAmt = (select MAX(ex.EstAmt) from Exp ex
where ex.Prot = p.ID and EstAmt > 0)
我有一个使用Mongoid 4(直接从GitHub的主分支)的Rails 4.0.3应用程序中的模型,我试图确保多个字段上的索引是唯一的,并删除重复项。 class MyModel
include Mongoid::Document
field :a, type: Integer
field :b, type: Integer
index({a: 1,