New answers tagged

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, ...


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 ...


0

Beginning On postgres 9.3, One trick you can use in postgres to get the exact sql of informational command (such as \d, \du, \dp, etc) in psql is by using a transaction. Here's how the trick goes. Open one postgres session, then type your command : begin; \dn+ While the transaction still running, open another postgres session, and query the ...


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

for all changes in table structure of two databases : SELECT table_schema, table_name, column_name,ordinal_position,data_type,column_type FROM ( SELECT table_schema, table_name, column_name,ordinal_position, data_type,column_type,COUNT(1) rowcount FROM information_schema.columns WHERE table_schema IN ('database1', 'database2') ...



Top 50 recent answers are included