The Players Table
CREATE TABLE [dbo]. [Players] ( [Id] INT NOT NULL, [Name] NCHAR (50) NOT NULL, [Age] INT NOT NULL, [Position] NCHAR (50) NOT NULL, [TeamId] INT NULL, PRIMARY KEY CLUSTERED ([Id] ASC), CONSTRAINT [FK_Players_Teams] FOREIGN KEY ([TeamId]) REFERENCES [dbo]. [Teams] ([Id]) ON DELETE SET NULL );
Answer 1, authority 100%
CONSTRAINT – a keyword that indicates that this section describes a constraint that is imposed on the data in the table and which will be checked by the server’s data integrity and consistency control subsystem , which in turn will not allow you to enter or change data in the table so that this condition is not met, and if the fact of the presence of data in the table that does not correspond to this condition is detected, it will be considered damaged. Immediately after this keyword, the unique identifier (name) of this constraint is indicated (it can be omitted, then the server will generate it automatically).
REFERENCES is a keyword that indicates that for each record of the table, the value of the expression described immediately before it will be checked for the presence of exactly the same value, including division into fragments, if any, the value in The unique index expression of the table immediately following this keyword. The control is performed by a subsystem for monitoring the integrity and consistency of server data. Any action that would lead to a violation of this compliance will be blocked. If any inconsistency is found, the data will be considered corrupted.
Answer 2, authority 50%
This is a constraint, in this case a foreign key. That is, the value of the
TeamId field is limited to the values contained in the
Id field of the
Teams table, or the