Hot answers tagged

3

Strictly speaking, _id fields are as unique as you make them. As you have discovered, the default values for _id are ObjectIDs but you can populate the field with any data you wish. Therefore, for example, you could use a UUID as I have done in this sharding example and then the chances of a collision across collections would essentially be whatever the ...


2

You want to track changes to the items at the item level so your item table would have a key that represents the 'item_id' and something else that distinguishes each state change for that item - you could use a timestamp or a counter or a flag. Let's generically call it 'version attribute'. Table Design [LIST] LIST_ID LIST_NAME -- other ...


1

If you want to force every child of every parent to have the same customer then there are two quick solutions that you could use to accomplish this. The first, and my preference, would be to use a check constraint on the table like so: -- define a function that performs the logic required CREATE FUNCTION dbo.fn_CheckCustomersAreEqual(ParentID INT, ...



Only top voted, non community-wiki answers of a minimum length are eligible