Professional Documents
Culture Documents
go
CREATE TABLE TBL_Users
(
userId int NOT NULL,
userTypeId int,
firstName nvarchar(255),
lastName nvarchar(255),
age int,
gender nvarchar(50),
email nvarchar(255),
userPassword nvarchar (255),
profileURL nvarchar(255),
--to be used in every SQL tables
entryUserId int,
modificationUserId int,
entryDate date,
modificationDate date,
isActive bit
--to be used in every SQL tables
PRIMARY KEY(userId),
FOREIGN KEY(userTypeId) REFERENCES TBL_userType(userTypeId)
);
CREATE TABLE TBL_userType(
userTypeId int,
userTypeName nvarchar(255),
--to be used in every SQL tables
entryUserId int,
modificationUserId int,
entryDate date,
modificationDate date,
isActive bit
--to be used in every SQL tables
PRIMARY KEY(userTypeId),
FOREIGN KEY(entryUserId) REFERENCES TBL_Users(userId),
FOREIGN KEY(modificationUserId) REFERENCES TBL_Users(userId)
);
entryDate date,
modificationDate date,
isActive bit
--to be used in every SQL tables
PRIMARY KEY(userCourseId),
FOREIGN KEY(userId) REFERENCES TBL_Users(userId),
FOREIGN KEY(courseId) REFERENCES TBL_courses(courseId),
FOREIGN KEY(entryUserId) REFERENCES TBL_Users(userId),
FOREIGN KEY(modificationUserId) REFERENCES TBL_Users(userId)
);
CREATE TABLE TBL_userRating(
ratingId int ,
userId int,
userCourseId int, --Link of icon on server
rating int,
--to be used in every SQL tables
entryUserId int,
modificationUserId int,
entryDate date,
modificationDate date,
isActive bit
--to be used in every SQL tables
PRIMARY KEY(ratingId),
FOREIGN KEY(userId) REFERENCES TBL_Users(userId),
FOREIGN KEY(userCourseId) REFERENCES TBL_userCourses(userCourseId),
FOREIGN KEY(entryUserId) REFERENCES TBL_Users(userId),
FOREIGN KEY(modificationUserId) REFERENCES TBL_Users(userId)
);
CREATE TABLE TBL_language(
languageId int ,
languageName nvarchar(255),
--to be used in every SQL tables
entryUserId int,
modificationUserId int,
entryDate date,
modificationDate date,
isActive bit
--to be used in every SQL tables
PRIMARY KEY(languageId),
FOREIGN KEY(entryUserId) REFERENCES TBL_Users(userId),
FOREIGN KEY(modificationUserId) REFERENCES TBL_Users(userId)
);
CREATE TABLE TBL_userTypeLanguage(
userTypeLanguageId int,
languageId int ,
userTypeLanguageName nvarchar(255),
userTypeId int,
--to be used in every SQL tables
entryUserId int,
modificationUserId int,
entryDate date,
modificationDate date,
isActive bit
--to be
PRIMARY
FOREIGN
FOREIGN
FOREIGN
FOREIGN
);