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

Sample Bookstore App: DB setup for Book Review Comments #5896

Merged
merged 7 commits into from
Mar 8, 2024
Merged
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
26 changes: 26 additions & 0 deletions code-samples/eventing/bookstore-sample-app/db/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Bookstore Database

1. Database Schema
2. Sample Data

## 1. Database Schema

### BookReviews Table
The BookReviews table contains all reviews made on the bookstore website.

See the columns of the BookReviews table below:
* ID (serial) - Primary Key
* post_time (datetime) - Posting time of the comment
* content (text) - The contents of the comment
* sentiment (text) - The sentiment results (currently, the values it could take on are 'positive' or 'neutral' or 'negative')

## 2. Sample Data

### BookReviews Table
The sample rows inserted for the BookReviews table are shown below:
| id | post_time | content | sentiment |
|----|---------------------|------------------------------|-----------|
| 1 | 2020-01-01 00:00:00 | This book is great! | positive |
| 2 | 2020-01-02 00:02:00 | This book is terrible! | negative |
| 3 | 2020-01-03 00:01:30 | This book is okay. | neutral |
| 4 | 2020-01-04 00:00:00 | Meh | neutral |
13 changes: 13 additions & 0 deletions code-samples/eventing/bookstore-sample-app/db/sample.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CREATE TABLE IF NOT EXISTS book_reviews(
id SERIAL PRIMARY KEY,
post_time timestamp NOT NULL,
content TEXT NOT NULL,
sentiment TEXT,
CONSTRAINT sentiment_check CHECK (sentiment IN ('positive', 'negative', 'neutral')),
);

INSERT INTO book_reviews (post_time, content, sentiment) VALUES
('2020-01-01 00:00:00', 'This book is great!', 'positive'),
('2020-01-02 00:02:00', 'This book is terrible!', 'negative'),
('2020-01-03 00:01:30', 'This book is okay.', 'neutral'),
('2020-01-04 00:00:00', 'Meh', 'neutral');