Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

As a developer, I want to use a database for persisting jokes. #32

Open
ice09 opened this issue Oct 25, 2021 · 0 comments
Open

As a developer, I want to use a database for persisting jokes. #32

ice09 opened this issue Oct 25, 2021 · 0 comments
Assignees

Comments

@ice09
Copy link
Collaborator

ice09 commented Oct 25, 2021

Description

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

SEA_CB drawio

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

@ice09 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
@ice09 ice09 added this to Backlog in Chuck-Mocked Oct 27, 2021
@Sup3rwoman Sup3rwoman moved this from Backlog to To Do in Chuck-Mocked Nov 4, 2021
@Sup3rwoman Sup3rwoman moved this from To Do to Doing in Chuck-Mocked Nov 4, 2021
@ice09 ice09 moved this from Doing to Done in Chuck-Mocked Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

5 participants