I need to perform a complete overhaul of two major systems. Taking a BI perspective, I created some baseline tables, "User", "CRM Details", "Telephony Details" etc.
I have an issue with understanding how relationships are formed between tables.
I dropped a list of users into the "Users" table, and I'll need to do the same into the "Telephony Details" table. How do I build a relationship where it knows 'John Smith' from Users = 'John Smith' in Telephony?
I anticipate the key columns will be "Id" in the Users table and therefore "UserId" in the Telephony table, but how does the UserId end up in the Telephony table?
Code I have so far:
CREATE TABLE Users
(
Id INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
Forename NVARCHAR(50),
Surname NVARCHAR(50),
Location CHAR(50),
Email NVARCHAR(320),
SCD_Start SMALLDATETIME,
SCD_Stop SMALLDATETIME,
IsActive BIT
)
INSERT INTO Users (Forename,Surname,Location,SCD_Start,SCD_Stop,IsActive)
VALUES ('Test1','Test1','TestL1','2016-11-08',NULL,1)
,('Test2','Test2','TestL2','2016-11-08',NULL,1)
,('Test3','Test3','TestL3','2016-11-08',NULL,1)
,('Test4','Test4','TestL4','2016-11-08',NULL,1)
,('Test5','Test5','TestL5','2016-11-08',NULL,1)
,('Test6','Test6','TestL6','2016-11-08',NULL,1)
CREATE TABLE Telephony
(
Id INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
Forename NVARCHAR(50),
Surname NVARCHAR(50),
OfficePhone VARCHAR(22),
MobilePhone VARCHAR(22),
SCD_Start SMALLDATETIME,
SCD_Stop SMALLDATETIME,
IsActive BIT
)