sql - Is it semantically correct to use a foreign key to indicate a range? -


I am trying to create a SQL table to represent a series of codes used by a third-party API I am So far, I have the following applause:

  create table api code (id it is not tap identity (1, 1) primary key, respccode code char (1) tap, respansubcod char (1) No NULL, ResponseSubSubCode char (1) NULL, MinorCodeRangeId Intel Zero References ApiMinorCodeRange, Description nvarchar (500)) Make Table ApiMinorCodeRange (id it not zero identity (1, 1) primary key, four from MainCode (4) No, Thermincorecode (4 ) No Taps) Table APIIM code (code four (4) tap primary key, detail Encryption (500)) Create  

The problem is, FromMinorCode and Thermyncore code can reference code that does not exist . For example: A category can indicate "5000 - 5ZZZ", but entries can only enter "code 5000 - 500A" in minor code new codes are added every few months Therefore, the ApiMinorCodeRange table requires reference to the full range defined in the specs.

I was planning to create foreign keys anyway and mark them NOCHECK :

  Add the ALTER table ApiMinorCodeRange Add FK_FromMinorCode Foreign Key ( FromMinorCode) ApiMinorCode ALTER Table ApiMinorCodeRange NOCHECK Obstacle FK_FromMinorCode ALTER Table Add ApiMinorCodeRange Reference Constraint FK_ThruMinorCode Foreign Key (ThruMinorCode) References ApiMinorCode Optional SQL APIDodernationsNorak Constant FK_ThruMinorCode  

Is this semantically correct?

Should SQL Server's query optimizer fix with foreign keys that refer to a fictional line?

Should I make a "dummy" instead of "5ZZZ - reserved for future use" instead of setting "token"?

You are trying to apply a business rule that will apply to codes that are y or Have not seen yet. A "right" way of doing this is not necessary.

Is there a valid code in relation to a boundary? I do not know why, for example, this is a group of encyclopedias (remember??) On each section such as:

  • AB
  • C
  • Stooge

I think the "sto" is not a valid entry in that volume. I think that "stochastic processing" will be in quantity.

Why should your code be different? More accurate in your case, your case may be in range (possibly) '5' to '5ZZZ' , even if no '5' There may be no valid code.

And, your rules can only extend beyond the boundaries. Maybe some big codes contain all the small codes that start with "5" and end with "Z".

My conclusion to the category is that the need for a foreign key relationship is not necessary.

He said, there is another problem that you want to deal with. Prevents the code from being in multiple categories? I suspect that you will need a trigger to implement this rule.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -