diff --git a/ERD-Dechboard.mwb b/ERD-Dechboard.mwb new file mode 100644 index 0000000..ac02bcb Binary files /dev/null and b/ERD-Dechboard.mwb differ diff --git a/ERD-Dechboard.mwb.bak b/ERD-Dechboard.mwb.bak new file mode 100644 index 0000000..32a1040 Binary files /dev/null and b/ERD-Dechboard.mwb.bak differ diff --git a/mysql-commands/README.txt b/mysql-commands/README.txt new file mode 100644 index 0000000..520ea74 --- /dev/null +++ b/mysql-commands/README.txt @@ -0,0 +1,8 @@ +This are the different tables what we implemented for the first sprint. + + +Important: + -NO CONSTRAINTS, TRIGGER and other DETAILS are not implemented yet . + -Considering the Data Proctection some data may be deleted or changed. + -Professor Jung has suggested to use MongoDB for the project. + diff --git a/mysql-commands/administrator.sql b/mysql-commands/administrator.sql new file mode 100644 index 0000000..d60d572 --- /dev/null +++ b/mysql-commands/administrator.sql @@ -0,0 +1,13 @@ +CREATE TABLE IF NOT EXISTS `administrator` ( + `adminID` bigint NOT NULL, + `password` varchar(32) NOT NULL, + `announcementNumber` bigint NOT NULL, + PRIMARY KEY (`adminID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf32; + +ALTER TABLE `administrator` +ADD CONSTRAINT `administrator_ibfk_1` +FOREIGN KEY (`adminID`) +REFERENCES `announcement` (`posterID`) +ON DELETE RESTRICT +ON UPDATE RESTRICT; \ No newline at end of file diff --git a/mysql-commands/announcement.sql b/mysql-commands/announcement.sql new file mode 100644 index 0000000..26de543 --- /dev/null +++ b/mysql-commands/announcement.sql @@ -0,0 +1,13 @@ +CREATE TABLE IF NOT EXISTS `announcement` ( + `announcementID` BIGINT NOT NULL AUTO_INCREMENT, + `createTime` TIMESTAMP NOT NULL, + `updateAt`TIMESTAMP NULL DEFAULT NULL, + `title` VARCHAR(50), + `content` varchar(140) NOT NULL, + `contentType`varchar(50), -- If special board, English, Algebra -- + `posterID` bigint NOT NULL, + `filetype` VARCHAR(16), + `fileURL` TEXT, + PRIMARY KEY (`announcementID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- Constrains fehlen -- + diff --git a/mysql-commands/comment.sql b/mysql-commands/comment.sql new file mode 100644 index 0000000..2287f63 --- /dev/null +++ b/mysql-commands/comment.sql @@ -0,0 +1,26 @@ +CREATE TABLE IF NOT EXISTS `comment` ( -- Comments on generated Posts -- + `commentID` BIGINT NOT NULL AUTO_INCREMENT, -- PK -- + `publisherID` BIGINT NOT NULL, -- ID from the commetator -- + `postId` BIGINT NOT NULL, -- ID from the commented post -- + `content` varchar(120) NOT NULL, -- some text -- + `createTime` timestamp NOT NULL, + `updatedAt`TIMESTAMP NULL DEFAULT NULL, + primary key (`commentId`), + KEY `publisherID` (`publisherID`), + KEY `commentReceiveID` (`commentReceiveID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- Constrains fehlen -- + +ALTER TABLE `comment` -- publisher Id as FK for post -- +ADD CONSTRAINT `fk_user_source` +FOREIGN KEY (`publisherId`) +REFERENCES `user` (`userId`) +ON DELETE NO ACTION +ON UPDATE NO ACTION; + +ALTER TABLE `comment` -- commentReceiveId as FK for post -- +ADD CONSTRAINT `fk_post_source` +FOREIGN KEY (`commentReceiveId`) +REFERENCES `post` (`postId`) +ON DELETE NO ACTION +ON UPDATE NO ACTION; + diff --git a/mysql-commands/friends.sql b/mysql-commands/friends.sql new file mode 100644 index 0000000..0cd2d20 --- /dev/null +++ b/mysql-commands/friends.sql @@ -0,0 +1,27 @@ +CREATE TABLE `friends` ( + `friendshipId` BIGINT NOT NULL AUTO_INCREMENT, + `sourceId` BIGINT NOT NULL, + `targetId` BIGINT NOT NULL, + `type` TINYINT, -- Mother, Neighboor, Student,etc... -- + `status` TINYINT NOT NULL, -- requested, refuse, ignored, ... -- + `createdAt` TIMESTAMP NOT NULL, + `notes` TEXT NULL DEFAULT NULL, + PRIMARY KEY (`friendshipId`), + +CONSTRAINT `fk_friend_source` -- SourceID as FK for user table -- +FOREIGN KEY (`sourceId`) +REFERENCES `user` (`userId`) +ON DELETE NO ACTION +ON UPDATE NO ACTION); + +ALTER TABLE `friends` +ADD UNIQUE `uq_friend`(`sourceId`, `targetId`); -- making friendship between 2 persons unique -- + +ALTER TABLE `friends` +ADD CONSTRAINT `fk_friend_target` -- TargetID as FK for user table -- +FOREIGN KEY (`targetId`) +REFERENCES `user` (`userId`) +ON DELETE NO ACTION +ON UPDATE NO ACTION; + + \ No newline at end of file diff --git a/mysql-commands/messages.sql b/mysql-commands/messages.sql new file mode 100644 index 0000000..0a1fbd2 --- /dev/null +++ b/mysql-commands/messages.sql @@ -0,0 +1,19 @@ +CREATE TABLE `messages` ( -- Chat messages -- + `messageId` BIGINT NOT NULL AUTO_INCREMENT, + `sourceId` BIGINT NOT NULL, -- Sender Id -- + `targetId` BIGINT NOT NULL, -- receiver Id-- + `content` TEXT, -- message text -- + `createdAt` TIMESTAMP NOT NULL, -- for tracking upload date -- + PRIMARY KEY (`messageId`), + CONSTRAINT `fk_umesssage_source` -- sourceId (sender) as FK for user table -- + FOREIGN KEY (`sourceId`) + REFERENCES `user` (`userId`) + ON DELETE NO ACTION + ON UPDATE NO ACTION); + +ALTER TABLE `messages` -- TargetId (receiver) as FK for user table -- +ADD CONSTRAINT `fk_umessage_target` + FOREIGN KEY (`targetId`) + REFERENCES `user` (`userId`) + ON DELETE NO ACTION + ON UPDATE NO ACTION; \ No newline at end of file diff --git a/mysql-commands/post.sql b/mysql-commands/post.sql new file mode 100644 index 0000000..0b85317 --- /dev/null +++ b/mysql-commands/post.sql @@ -0,0 +1,24 @@ +CREATE TABLE IF NOT EXISTS `post` ( + `postId` BIGINT NOT NULL AUTO_INCREMENT, + `publisherId` BIGINT NOT NULL, + `title` VARCHAR(50), + `status` TINYINT NOT NULL, -- private = 1 , public = 2 or important = 3 -- + `content` VARCHAR(140) NOT NULL, + `boardType`VARCHAR(50), -- If special board, English, Algebra -- + `createTime` TIMESTAMP NOT NULL, + `updateAt`TIMESTAMP NULL DEFAULT NULL , -- this contains the last updated date-- + `commentCounter` BIGINT NOT NULL, -- counter for accumulated number of comments -- + `upvotes` BIGINT, + `downvotes` BIGINT, + `filetype` VARCHAR(16), + `fileURL` TEXT, + PRIMARY KEY (`postId`), +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +ALTER TABLE `post` +ADD CONSTRAINT `fk_upost_user` -- publisherID as FK for user table -- +FOREIGN KEY (`publisherId`) -- Delete the post without deleting the user -- +REFERENCES `user` (`userId`) +ON DELETE NO ACTION +ON UPDATE NO ACTION; + diff --git a/mysql-commands/user.sql b/mysql-commands/user.sql new file mode 100644 index 0000000..dba5b2f --- /dev/null +++ b/mysql-commands/user.sql @@ -0,0 +1,22 @@ + CREATE TABLE IF NOT EXISTS `dechboard`.`user` ( + `userId` BIGINT NOT NULL AUTO_INCREMENT, + `firstName` VARCHAR(50) NOT NULL, + `lastName` VARCHAR(50) NOT NULL, + `userName` VARCHAR(50) NULL DEFAULT NULL, + `phoneNumber` VARCHAR(15) NULL, + `email` VARCHAR(50) NOT NULL, + `profilePicture` BLOB, + `passwordHash` VARCHAR(32) NOT NULL, -- only storing the hash -- + `intro` VARCHAR(50) NULL DEFAULT NULL, -- short Text for introduce yourself -- + `gender`TINYINT NOT NULL, -- 1 = man, 2 = women , 3 = divers -- + `birthday` DATETIME NOT NULL, + `status` VARCHAR (50) NOT NULL, -- this specifies Student or Teacher -- + + PRIMARY KEY (`userId`), + UNIQUE INDEX `uq_userName` (`userName` ASC), + UNIQUE INDEX `uq_phoneNumber` (`phoneNumber` ASC), + UNIQUE INDEX `uq_email` (`email` ASC) ) + ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; +SET time_zone = "+00:00"; +-- Constrains fehlen -- \ No newline at end of file