Sie sind auf Seite 1von 4

use [LearnNet]

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)
);

CREATE TABLE TBL_category(


categoryId int,
categoryName 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(categoryId),
FOREIGN KEY(entryUserId) REFERENCES TBL_Users(userId),

FOREIGN KEY(modificationUserId) REFERENCES TBL_Users(userId)


);
CREATE TABLE TBL_courses(
courseId int ,
categoryId int,
courseName nvarchar(255), --Link of icon on server
courseTitle nvarchar(255),
authorId int,
authorName nvarchar(255),
courseCost money,
coursePriceSale money,
--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(courseId),
FOREIGN KEY(categoryId) REFERENCES TBL_category(categoryId),
FOREIGN KEY(entryUserId) REFERENCES TBL_Users(userId),
FOREIGN KEY(modificationUserId) REFERENCES TBL_Users(userId)
);
CREATE TABLE TBL_courseContent(
courseContentId int ,
courseId int,
attachementTitle nvarchar(255), --Link of icon on server
attachementLink 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(courseContentId),
FOREIGN KEY(courseId) REFERENCES TBL_courses(courseId),
FOREIGN KEY(entryUserId) REFERENCES TBL_Users(userId),
FOREIGN KEY(modificationUserId) REFERENCES TBL_Users(userId)
);
CREATE TABLE TBL_userCourses(
userCourseId int ,
userId int,
courseId int, --Link of icon on server
isPurchased bit,
isInWhishlist bit,
--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(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
);

used in every SQL tables


KEY(userTypeLanguageId),
KEY(languageId) REFERENCES TBL_language(languageId),
KEY(userTypeId) REFERENCES TBL_userType(userTypeId),
KEY(entryUserId) REFERENCES TBL_Users(userId),
KEY(modificationUserId) REFERENCES TBL_Users(userId)

CREATE TABLE TBL_categoryLanguage(


categoryLanguageId int,
languageId int ,
categoryLanguageName nvarchar(255),
categoryId 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(categoryLanguageId),
FOREIGN KEY(languageId) REFERENCES TBL_language(languageId),
FOREIGN KEY(categoryId) REFERENCES TBL_category(categoryId),
FOREIGN KEY(entryUserId) REFERENCES TBL_Users(userId),
FOREIGN KEY(modificationUserId) REFERENCES TBL_Users(userId)
);
CREATE TABLE TBL_courseLanguage(
courseLanguageId int,
languageId int ,
courseLanguageName nvarchar(255),
courseId 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(courseLanguageId),
FOREIGN KEY(languageId) REFERENCES TBL_language(languageId),
FOREIGN KEY(courseId) REFERENCES TBL_courses(courseId),
FOREIGN KEY(entryUserId) REFERENCES TBL_Users(userId),
FOREIGN KEY(modificationUserId) REFERENCES TBL_Users(userId)
);

Das könnte Ihnen auch gefallen