You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently only a file-based persistence is implemented. This does not allow for more complex data structures like User->Joke or Joke->Ratings. Therefore, the file-based persistence should be deprecated for a relational database persistence.
Overview
Setup MySQL
# CREATE USER AND DATABASE
CREATE USER 'chuck'@'localhost' IDENTIFIED BY 'norris';
CREATE DATABASE chuckbot;
GRANT ALL PRIVILEGES ON chuckbot.* TO 'chuck'@'localhost';
FLUSH PRIVILEGES;
# CREATE TABLE
CREATE TABLE JOKES (
ID int NOT NULL AUTO_INCREMENT,
JOKETEXT text NOT NULL,
ADDED date,
PRIMARY KEY (ID)
);
# INSERT TEST DATA
INSERT INTO JOKES (JOKETEXT, ADDED) VALUES ('Chuck Norris kann Feuer mit einer Lupe machen – nachts!', NOW());
INSERT INTO JOKES (JOKETEXT, ADDED) VALUES ('Chuck Norris läuft 100 Meter in einer Sekunde. Er kennt immer eine Abkürzung.', NOW());
INSERT INTO JOKES (JOKETEXT, ADDED) VALUES ('Chuck Norris kann ein Feuer entfachen, indem er zwei Eiswürfel aneinander reibt.', NOW());
INSERT INTO JOKES (JOKETEXT, ADDED) VALUES ('Chuck Norris wurde gestern geblitzt – beim Einparken.', NOW());
INSERT INTO JOKES (JOKETEXT, ADDED) VALUES ('Wenn man Chuck Norris fragt, wie viele Liegestütze er schafft, antwortet er: "Alle."', NOW());
INSERT INTO JOKES (JOKETEXT, ADDED) VALUES ('Chuck Norris kann ein Fünfeck zeichnen – mit vier Strichen.', NOW());
INSERT INTO JOKES (JOKETEXT, ADDED) VALUES ('Chuck Norris entführt Aliens.', NOW());
INSERT INTO JOKES (JOKETEXT, ADDED) VALUES ('Chuck Norris kann Drehtüren zuknallen.', NOW());
INSERT INTO JOKES (JOKETEXT, ADDED) VALUES ('Chuck Norris kann Atom- von Ökostrom unterscheiden – und zwar am Geschmack.', NOW());
INSERT INTO JOKES (JOKETEXT, ADDED) VALUES ('Chuck Norris hat bis Unendlich gezählt. Zweimal.', NOW());
Acceptance Criteria
A new class DBPersistence implements JokePersistence and uses a local MySQL database connection.
Dependencies
Tests
Deliverables
The text was updated successfully, but these errors were encountered:
ice09
changed the title
As a developer, I want to use a database for persisting jokes
As a developer, I want to use a database for persisting jokes.
Oct 25, 2021
Description
Currently only a file-based persistence is implemented. This does not allow for more complex data structures like
User
->Joke
orJoke
->Ratings
. Therefore, the file-based persistence should be deprecated for a relational database persistence.Overview
Setup MySQL
Acceptance Criteria
DBPersistence
implementsJokePersistence
and uses a local MySQL database connection.Dependencies
Tests
Deliverables
The text was updated successfully, but these errors were encountered: