Skip to content

Commit

Permalink
Sample Bookstore App: DB setup for Book Review Comments (knative#5896)
Browse files Browse the repository at this point in the history
* first commit, made table and wrote docs

* removed book id

* reduced amt of sample data

* Update code-samples/eventing/bookstore-sample-app/db/sample.sql

Co-authored-by: Calum Murray <[email protected]>

* Update code-samples/eventing/bookstore-sample-app/db/sample.sql

Co-authored-by: Calum Murray <[email protected]>

* Update code-samples/eventing/bookstore-sample-app/db/sample.sql

Co-authored-by: Calum Murray <[email protected]>

* Update code-samples/eventing/bookstore-sample-app/db/sample.sql

Co-authored-by: Calum Murray <[email protected]>

---------

Co-authored-by: Calum Murray <[email protected]>
  • Loading branch information
2 people authored and prushh committed Apr 30, 2024
1 parent a9b6a56 commit d2547d2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
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');

0 comments on commit d2547d2

Please sign in to comment.