Replies: 14 comments 4 replies
-
Hello @dirk-jacobs , We will discus about the db schema in details tomorrow |
Beta Was this translation helpful? Give feedback.
-
variations of the first version, maybe it would be enough to use |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Question please, do we already make a decision which and how many categories of the goods that we're going to use? |
Beta Was this translation helpful? Give feedback.
-
CREATE TABLE "user" (
"id" serial NOT NULL,
"first_name" varchar(50) NOT NULL,
"last_name" varchar(50) NOT NULL,
"e_mail" varchar(255) NOT NULL UNIQUE,
"street" varchar(255),
"password" varchar(255) NOT NULL,
"phone" varchar(255),
"age" int,
"registered_at" DATE NOT NULL,
"is_needer" BOOLEAN,
"is_giver" BOOLEAN,
"description" TEXT NOT NULL,
"agreement" BOOLEAN NOT NULL,
CONSTRAINT "user_pk" PRIMARY KEY ("id")
) WITH (
OIDS=FALSE
);
CREATE TABLE "goods" (
"id" serial NOT NULL,
"giver_id" int NOT NULL,
"item_name" varchar(255) NOT NULL,
"category" varchar(255) NOT NULL,
"description" TEXT NOT NULL,
"image" bytea NOT NULL,
"quality" int NOT NULL,
"quantity" int NOT NULL,
"available" BOOLEAN NOT NULL,
"posted_at" DATE NOT NULL,
"taken" BOOLEAN NOT NULL,
"owner_id" int NOT NULL,
CONSTRAINT "goods_pk" PRIMARY KEY ("id")
) WITH (
OIDS=FALSE
);
CREATE TABLE "good for many needers" (
"id" serial NOT NULL,
"good_id" int NOT NULL,
"needer_id" int NOT NULL,
CONSTRAINT "good for many needers_pk" PRIMARY KEY ("id")
) WITH (
OIDS=FALSE
);
ALTER TABLE "goods" ADD CONSTRAINT "goods_fk0" FOREIGN KEY ("giver_id") REFERENCES "user"("id");
ALTER TABLE "goods" ADD CONSTRAINT "goods_fk1" FOREIGN KEY ("owner_id") REFERENCES "user"("id");
ALTER TABLE "good for many needers" ADD CONSTRAINT "good for many needers_fk0" FOREIGN KEY ("good_id") REFERENCES "goods"("id");
ALTER TABLE "good for many needers" ADD CONSTRAINT "good for many needers_fk1" FOREIGN KEY ("needer_id") REFERENCES "user"("id"); |
Beta Was this translation helpful? Give feedback.
-
categories updated: 11/5/2021 CREATE TABLE "user" (
"id" serial NOT NULL,
"first_name" varchar(50) NOT NULL,
"last_name" varchar(50) NOT NULL,
"e_mail" varchar(255) NOT NULL UNIQUE,
"street" varchar(255),
"password" varchar(255) NOT NULL,
"phone" varchar(255),
"age" int,
"registered_at" DATE NOT NULL,
"is_needer" BOOLEAN,
"is_giver" BOOLEAN,
"description" TEXT NOT NULL,
"agreement" BOOLEAN NOT NULL,
CONSTRAINT "user_pk" PRIMARY KEY ("id")
) WITH (
OIDS=FALSE
);
CREATE TABLE "goods" (
"id" serial NOT NULL,
"giver_id" int NOT NULL,
"item_name" varchar(255) NOT NULL,
"category" varchar(255) NOT NULL,
"description" TEXT NOT NULL,
"image" bytea NOT NULL,
"quality" int NOT NULL,
"quantity" int NOT NULL,
"available" BOOLEAN NOT NULL,
"posted_at" DATE NOT NULL,
"taken" BOOLEAN NOT NULL,
"owner_id" int NOT NULL,
"category_id" int NOT NULL,
CONSTRAINT "goods_pk" PRIMARY KEY ("id")
) WITH (
OIDS=FALSE
);
CREATE TABLE "good for many needers" (
"id" serial NOT NULL,
"good_id" int NOT NULL,
"needer_id" int NOT NULL,
CONSTRAINT "good for many needers_pk" PRIMARY KEY ("id")
) WITH (
OIDS=FALSE
);
CREATE TABLE "categories" (
"id" serial NOT NULL,
"category_name" varchar(50) NOT NULL,
CONSTRAINT "categories_pk" PRIMARY KEY ("id")
) WITH (
OIDS=FALSE
);
CREATE TABLE "tags" (
"id" serial NOT NULL,
"category_id" int NOT NULL,
"tag_name" varchar(50) NOT NULL,
CONSTRAINT "tags_pk" PRIMARY KEY ("id")
) WITH (
OIDS=FALSE
);
ALTER TABLE "goods" ADD CONSTRAINT "goods_fk0" FOREIGN KEY ("giver_id") REFERENCES "user"("id");
ALTER TABLE "goods" ADD CONSTRAINT "goods_fk1" FOREIGN KEY ("owner_id") REFERENCES "user"("id");
ALTER TABLE "goods" ADD CONSTRAINT "goods_fk2" FOREIGN KEY ("category_id") REFERENCES "categories"("id");
ALTER TABLE "good for many needers" ADD CONSTRAINT "good for many needers_fk0" FOREIGN KEY ("good_id") REFERENCES "goods"("id");
ALTER TABLE "good for many needers" ADD CONSTRAINT "good for many needers_fk1" FOREIGN KEY ("needer_id") REFERENCES "user"("id");
ALTER TABLE "tags" ADD CONSTRAINT "tags_fk0" FOREIGN KEY ("category_id") REFERENCES "categories"("id");
|
Beta Was this translation helpful? Give feedback.
-
If we want to be able to upload multiple images for one post, we should have a table called |
Beta Was this translation helpful? Give feedback.
-
Brain: maybe we need many end-points for the categories, like in |
Beta Was this translation helpful? Give feedback.
-
week 3
https://github.com/hyf-Group2-fp/Just4Giving/issues show the goods - Brain 2.7 |
Beta Was this translation helpful? Give feedback.
-
week 4postman's collection: {
"info": {
"_postman_id": "e29ec07a-351e-4d34-815c-45861110412d",
"name": "just4Giving",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Get the home",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "localhost:5000/api/home",
"host": [
"localhost"
],
"port": "5000",
"path": [
"api",
"home"
]
},
"description": "Get the home"
},
"response": []
},
{
"name": "Create a giver",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n\t\"first_name\": \"giver1\",\n \"last_name\": \"giver1\",\n \"email\": \"giver1@doe.com\",\n \"password\": \"1234\",\n \"street\": \"street 1\",\n \"phone\": \"123456\",\n \"age\": 30,\n \"is_giver\": 1,\n \"is_needer\": 0,\n \"description\": \"no description\",\n \"agreement\": 1\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:5000/api/needer/signup",
"protocol": "http",
"host": [
"localhost"
],
"port": "5000",
"path": [
"api",
"needer",
"signup"
]
}
},
"response": []
},
{
"name": "Create a needer",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n\t\"first_name\": \"needer1\",\n \"last_name\": \"needer1\",\n \"email\": \"needer1@doe.com\",\n \"password\": \"123456789\",\n \"street\": \"street 1\",\n \"phone\": \"123456\",\n \"age\": 30,\n \"is_giver\": 1,\n \"is_needer\": 0,\n \"description\": \"fdsjfhkffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffjsdh\",\n \"agreement\": 1\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:5000/api/giver/signup",
"protocol": "http",
"host": [
"localhost"
],
"port": "5000",
"path": [
"api",
"giver",
"signup"
]
}
},
"response": []
},
{
"name": "Login authenticate",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n\t\"email\": \"aldo@scotti.com\",\n\t\"password\":\"123456789\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:5000/api/authenticate",
"protocol": "http",
"host": [
"localhost"
],
"port": "5000",
"path": [
"api",
"authenticate"
]
},
"description": "Login authenticate"
},
"response": []
},
{
"name": "Check the Token",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtYWlsIjoiYWxkb0BzY290dGkuY29tIiwiaWF0IjoxNjIxNDE1NzI2LCJleHAiOjE2MjE0MTkzMjZ9.ga5xzjUfSy0I1q_t9PlvqLEavsE7TJX7jeXm_8dPBxg",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
},
{
"key": "x-auth-token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtYWlsIjoiYWxkb0BzY290dGkuY29tIiwiaWF0IjoxNjIxNjAwNzQ0LCJleHAiOjE2MjE2MDQzNDR9.J7OAgvHvepsnWUQVX04IWRaG-lsZCEVWYQtzzm3Nvrc",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:5000/api/checkToken",
"protocol": "http",
"host": [
"localhost"
],
"port": "5000",
"path": [
"api",
"checkToken"
]
},
"description": "Check the Token"
},
"response": []
},
{
"name": "Edit a good",
"request": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n\t\"item_name\": \"new name\"\n}\n",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:5000/api/goods/1",
"protocol": "http",
"host": [
"localhost"
],
"port": "5000",
"path": [
"api",
"goods",
"1"
]
},
"description": "Edit a good"
},
"response": []
},
{
"name": "Delete good",
"request": {
"method": "DELETE",
"header": [],
"url": {
"raw": "http://localhost:5000/api/goods/1",
"protocol": "http",
"host": [
"localhost"
],
"port": "5000",
"path": [
"api",
"goods",
"1"
]
},
"description": "Delete good"
},
"response": []
},
{
"name": "Get a good by id",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:5000/api/goods/12",
"protocol": "http",
"host": [
"localhost"
],
"port": "5000",
"path": [
"api",
"goods",
"12"
]
},
"description": "Get a good by id"
},
"response": []
},
{
"name": "Get goods by user id",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:5000/api/user/goods/65",
"protocol": "http",
"host": [
"localhost"
],
"port": "5000",
"path": [
"api",
"user",
"goods",
"65"
]
},
"description": "Get goods by user id"
},
"response": []
},
{
"name": "Create good",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"giver_id\": 65,\n \"item_name\": \"sofa\",\n \"category\": \"Furnitures\",\n \"description\": \"asomething else\",\n \"image\": \"\",\n \"quality\": 1,\n \"quantity\": 1,\n \"available\": 1,\n \"taken\": 0,\n \"owner_id\": 65,\n \"category_id\": 2,\n \"createdAt\": \"2021-05-19T17:52:20.000Z\",\n \"updatedAt\": \"2021-05-19T17:52:20.000Z\"\n}\n",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:5000/api/goods",
"protocol": "http",
"host": [
"localhost"
],
"port": "5000",
"path": [
"api",
"goods"
]
},
"description": "Create good"
},
"response": []
},
{
"name": "Get all the categories",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:5000/api/categories",
"protocol": "http",
"host": [
"localhost"
],
"port": "5000",
"path": [
"api",
"categories"
]
},
"description": "Get all the categories"
},
"response": []
},
{
"name": "Edit category",
"request": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"category_name\": \"Used Furniture\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:5000/api/categories/2",
"protocol": "http",
"host": [
"localhost"
],
"port": "5000",
"path": [
"api",
"categories",
"2"
]
},
"description": "Edit category"
},
"response": []
},
{
"name": "Delete category",
"request": {
"method": "DELETE",
"header": [],
"url": {
"raw": "http://localhost:5000/api/categories/2",
"protocol": "http",
"host": [
"localhost"
],
"port": "5000",
"path": [
"api",
"categories",
"2"
]
},
"description": "Delete category"
},
"response": []
},
{
"name": "Get goods per single category id",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:5000/api/goods/category/2",
"protocol": "http",
"host": [
"localhost"
],
"port": "5000",
"path": [
"api",
"goods",
"category",
"2"
]
},
"description": "Get goods per single category id"
},
"response": []
},
{
"name": "Create new category",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"category_name\": \"Furnitures\",\n \"createdAt\": \"2021-05-18T14:35:44.000Z\",\n \"updatedAt\": \"2021-05-18T14:35:44.000Z\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "localhost:5000/api/categories",
"host": [
"localhost"
],
"port": "5000",
"path": [
"api",
"categories"
]
},
"description": "Create new category"
},
"response": []
},
{
"name": "Get all the goods",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "localhost:5000/api/goods",
"host": [
"localhost"
],
"port": "5000",
"path": [
"api",
"goods"
]
},
"description": "Get all the goods"
},
"response": []
}
],
"protocolProfileBehavior": {}
}
|
Beta Was this translation helpful? Give feedback.
-
Everything about the Back-End ....
Beta Was this translation helpful? Give feedback.
All reactions