Skip to content
Snippets Groups Projects
Commit 3c0e64be authored by Sercan Yesildal's avatar Sercan Yesildal
Browse files

db added

parent e17b8e42
No related branches found
No related tags found
No related merge requests found
{
"addr": ":3306",
"dbName": "planner",
"user": "root",
"passwd": "secret"
}
\ No newline at end of file
CREATE DATABASE IF NOT EXISTS planner;
USE planner;
CREATE TABLE IF NOT EXISTS `userAccount` (
`id` int NOT NULL AUTO_INCREMENT,
`mail` varchar(255) NOT NULL,
`firstName` varchar(255) NOT NULL,
`lastName` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE IF NOT EXISTS `userGroup` (
`id` int NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
);
CREATE TABLE IF NOT EXISTS `userMeal` (
`id` int NOT NULL AUTO_INCREMENT,
`userId` int NOT NULL,
`mealId` int NOT NULL,
`date` DATE NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`userId`) REFERENCES userAccount(`id`)
);
CREATE TABLE IF NOT EXISTS `groupMeal` (
`id` int NOT NULL AUTO_INCREMENT,
`groupId` int NOT NULL,
`mealId` int NOT NULL,
`date` DATE NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`groupId`) REFERENCES userGroup(`id`)
);
CREATE TABLE IF NOT EXISTS `shoppingDate` (
`id` int NOT NULL AUTO_INCREMENT,
`userId` int NOT NULL,
`date` DATE NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`userId`) REFERENCES userAccount(`id`)
);
CREATE TABLE IF NOT EXISTS `userGroupRelation` (
`id` int NOT NULL AUTO_INCREMENT,
`groupId` int NOT NULL,
`userId` int NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`groupId`) REFERENCES userGroup(`id`),
FOREIGN KEY (`userId`) REFERENCES userAccount(`id`)
);
\ No newline at end of file
package model
type Group struct {
ID uint `json:"id"`
UserIDs []uint `json:"userIds"`
Meals []MealGroup `json:"meals"`
ID int `json:"id"`
UserIDs []int `json:"userIds"`
Meals []GroupMeal `json:"meals"`
}
package model
type Meal struct {
type UserMeal struct {
UserID int `json:"userId"`
MealID int `json:"mealId"`
Date string `json:"date"`
}
type MealUser struct {
UserID uint `json:"userId"`
Meal
}
type MealGroup struct {
GroupID uint `json:"groupId"`
Meal
type GroupMeal struct {
GroupID int `json:"groupId"`
MealID int `json:"mealId"`
Date string `json:"date"`
}
package model
type ShoppingDate struct {
UserID uint `json:"userId"`
UserID int `json:"userId"`
Date string `json:"date"`
}
package model
type User struct {
ID uint `json:"id"`
ID int `json:"id"`
Mail string `json:"mail"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Meals []MealUser `json:"meals"`
Meals []UserMeal `json:"meals"`
ShoppingDates []ShoppingDate `json:"shoppingDates"`
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment