I need to compile a table for some new components that will track available and used resources. It will be something like this:
CREATE TABLE components ( component_Id int NOT NULL PRIMARY KEY, workOrder_Id int FOREIGN KEY, componentSerial varchar(25) NOT NULL, foo varchar(50), bar int, information nvarchar(250) date DateTime )
What are the benefits of making workOrderID FOREIGN KEY null if not already used, not NOT NULL and defaults to 0? For me, this means that a nullable value makes sense.
I looked at some similar situations, but I'm not sure why someone chose one of them.
0, , workOrder 0, workOrder . .
(, FOREIGN KEY , , , , , , MyISAM. , FOREIGN KEY , , REFERENCES SQL.)
FOREIGN KEY
REFERENCES
NULL, - workOrders UNIQUE _Id.
, : , NULL " ", .
Source: https://habr.com/ru/post/1761996/More articles:Apostrophes and SQL Server FT Search - sql-serverCreate and submit complex content to a GUI stream in WPF / C # - c #Inherit active_record on rails - inheritanceDisplaying form data after submitting - phpPHP providing closure to uniqueness of an element in an array - closuresHow to convert varchar with hex value to int? - sql-serverWhat are the Amazon Kindle user agent strings? - user-agentPerl for static linux executable - linuxHow to implement custom escape sequence when using split () in perl? - splitpreg_replace multiple instances in 1 line? - phpAll Articles