Hello,
I have a question about good and bad practise with Primary and Foreign keys. Is it good idea/practise to use second table for extra info about the person using firsts( Users ) table PK as PK and FK on second( Address ) table ? I am planing to create more tables like ADDRESS table.
Or should I avoid doing so ? If yes, why and what would be a better choice ?
CREATE TABLE Users.Users ( UserID INT NOT NULL IDENTITY(30,1), FirstName NVARCHAR(50) NOT NULL, MiddleName NVARCHAR(50) NULL, LastName NVARCHAR(50) NOT NULL, DateOfBirth DATE NULL, CreationDate DATETIME2 NOT NULL DEFAULT(GETDATE()), SSMA_TimeStamp TIMESTAMP NOT NULL, CONSTRAINT PK_UserID PRIMARY KEY(UserID), CONSTRAINT CHK_DateOfBirth CHECK(DateOfBirth <= CURRENT_TIMESTAMP) ); CREATE TABLE Users.Address ( UserID INT NOT NULL, Country NVARCHAR(50) NULL, County NVARCHAR(50) NULL, City NVARCHAR(50) NULL, AddressLine1 NVARCHAR(100) NULL, AddressLine2 NVARCHAR(100) NULL, PostCode NVARCHAR(15) NULL, CONSTRAINT PK_AddressUserID PRIMARY KEY(UserID),CONSTRAINT FK_UserID_UsersUserID FOREIGN KEY (UserID)REFERENCES Users.Users (UserID), );