Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added ERD-Dechboard.mwb
Binary file not shown.
Binary file added ERD-Dechboard.mwb.bak
Binary file not shown.
8 changes: 8 additions & 0 deletions mysql-commands/README.txt
Original file line number Diff line number Diff line change
@@ -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.

13 changes: 13 additions & 0 deletions mysql-commands/administrator.sql
Original file line number Diff line number Diff line change
@@ -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;
13 changes: 13 additions & 0 deletions mysql-commands/announcement.sql
Original file line number Diff line number Diff line change
@@ -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 --

26 changes: 26 additions & 0 deletions mysql-commands/comment.sql
Original file line number Diff line number Diff line change
@@ -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;

27 changes: 27 additions & 0 deletions mysql-commands/friends.sql
Original file line number Diff line number Diff line change
@@ -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;


19 changes: 19 additions & 0 deletions mysql-commands/messages.sql
Original file line number Diff line number Diff line change
@@ -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;
24 changes: 24 additions & 0 deletions mysql-commands/post.sql
Original file line number Diff line number Diff line change
@@ -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;

22 changes: 22 additions & 0 deletions mysql-commands/user.sql
Original file line number Diff line number Diff line change
@@ -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 --