我不确定构建问题的最佳方法是什么。
我有一个带有外键列的表。 默认情况下,外键设置为NOT NULL ,我想暂时保留它,因为这可能是最终的结果。 但是现在可能有记录不需要(并且有)外键值,我想以某种方式区分它们,所以尽可能清楚这些记录与另一些记录不同。
我试过,但似乎我不能使用bigint负数,这是我的SQL Server表中的外键的值。 我想这是非常标准的东西,除了将外键设为NULL之外,在这种情况下最好的做法是什么?
I'm not sure what is the best way to structure my question.
I have a table with foreign key column in it. By default the foreign key is set to NOT NULL and I want to keep it that way for now, because maybe this will be the final result. But for now there could be records that don't need (and have) foreign keys values and I want to distinct them somehow so it is as clear as possible that these records are something different from the other.
I tried but as it seems I can not use negative numbers for bigint which is the value of the foreign key in my SQL Server table. I guess this is pretty standard stuff so what is the best thing to do in this situation besides making the foreign key to NULL?
最满意答案
不知道为什么HABO没有得到答案,因为这几乎是你唯一的选择。
将其设为NULL 在引用的表中创建一行并将其设置为TBD或您喜欢的任何名字对象,并使用其中的ID而不是NULL如果您的记录不需要FK且永远不会,那么您应该将列设置为NULL,否则使用临时值。
您不能使用负值,因为如果您有外键约束,您必须引用外表中的某些内容。
Not sure why HABO didn't make that the answer, because that's pretty much your only option.
Make it NULL Create a row in the referenced table and set it to TBD or whatever moniker you prefer and use the ID from that instead of NULLIf you have records that do not need an FK and never will, then you should set the column to NULL, else use a temp value.
You cannot use a negative value because you MUST reference something in the foreign table if you have a foreign key constraint.
更多推荐
发布评论