# Define the book review entity · Your first Rell app on Chromia · Learn Chromia

> With the book entity in place, you can add a second entity, book_review, to store reviews of those books. The model looks like this:

Source: https://chromia.com/learn/book-review/book-review-entity/tables/

Your first Rell app on ChromiaLesson 9 of 26

1. [01Your first Rell app on Chromia](https://chromia.com/learn/book-review/introduction/)
2. [02Set up your project](https://chromia.com/learn/book-review/setup/)
3. [03Rell project structure](https://chromia.com/learn/book-review/rell-structure/)

Part 1: Define your first entity

1. [04Overview](https://chromia.com/learn/book-review/book-entity/)
2. [05Create your first entity](https://chromia.com/learn/book-review/book-entity/tables/)
3. [06Add your first operation](https://chromia.com/learn/book-review/book-entity/basic-operations/)
4. [07Query every book](https://chromia.com/learn/book-review/book-entity/write-queries/)

Part 2: Add a related entity

1. [08Overview](https://chromia.com/learn/book-review/book-review-entity/)
2. [09Define the book review entity](https://chromia.com/learn/book-review/book-review-entity/tables/)
3. [10Add an operation for creating book reviews](https://chromia.com/learn/book-review/book-review-entity/basic-operations/)
4. [11Query all reviews for a book](https://chromia.com/learn/book-review/book-review-entity/write-queries/)

Part 3: Checking and validating inputs

1. [12Overview](https://chromia.com/learn/book-review/input-verification/)
2. [13Verify inputs](https://chromia.com/learn/book-review/input-verification/input-verification/)
3. [14Return structured results from queries](https://chromia.com/learn/book-review/input-verification/structure/)

Part 4: Signing transactions and filtering queries

1. [15Overview](https://chromia.com/learn/book-review/sign-transaction/)
2. [16Sign a transaction](https://chromia.com/learn/book-review/sign-transaction/sign-transaction/)
3. [17Filter and sort query results](https://chromia.com/learn/book-review/sign-transaction/structure/)

Part 5: Blockchain state and transactions explained

1. [18Overview](https://chromia.com/learn/book-review/blockchain-transactions/)
2. [19How blockchain state and transactions work](https://chromia.com/learn/book-review/blockchain-transactions/query-transaction/)
3. [20Walking through an example](https://chromia.com/learn/book-review/blockchain-transactions/example/)

Part 6: Create the client

1. [21Overview](https://chromia.com/learn/book-review/build-client/)
2. [22Prerequisites](https://chromia.com/learn/book-review/build-client/prerequisites/)
3. [23Establishing a connection to Chromia](https://chromia.com/learn/book-review/build-client/sign-transaction/)
4. [24Query the blockchain using postchain-client](https://chromia.com/learn/book-review/build-client/query-blockchain/)
5. [25Complete the example](https://chromia.com/learn/book-review/build-client/complete-example/)

1. [26What’s next?](https://chromia.com/learn/book-review/what-next/)

[Learn](https://chromia.com/learn/)[Your first Rell app on Chromia](https://chromia.com/learn/book-review/)

09 / 26Part 2: Add a related entityBeginner

# Define the book review entity

With the `book` entity in place, you can add a second entity, `book_review`, to store reviews of those books. The model looks like this:

## Adding the book review entity

Open `src/main/entities.rell` and add the following definition for `book_review`:

src/main/entities.rell

```
entity book_review {
  index book: book;
  reviewer_name: text;
  review: text;
  rating: integer;
}
```

info

**Linking & implicit joins**

The `book_review` entity holds a reference to `book`. Internally, Rell saves the **`rowid`** of the referenced row, which ties each review to the book it belongs to.

* **If your query or operation starts at `book_review` and reads fields through `.book`**  
  (for example `.book.title`, `.book.to_struct()`, or `@sort .book.author`), Rell joins `book_review` and `book` implicitly to fetch those values.
* Reading only fields that belong to `book_review` triggers **no join**.
* An expression that starts at the `book` entity is already working on that entity, so no additional join is needed.

tip

Every reference you dereference results in a separate implicit join. When an entity has many references and you fetch all of them at once (for example with `.to_struct()`), the expression runs several joins, which can slow things down on large datasets.

### Breakdown of the code

* **`entity` keyword:** Declares a new entity, comparable to creating a table in a SQL database.
* **`index book: book;`**: This attribute references a `book`, connecting each review to its book. The `index` keyword speeds up queries that go through this relationship.
* **`reviewer_name: text;`**: Holds the name or alias the reviewer chooses to use.
* **`review: text;`**: Holds the review itself as text.
* **`rating: integer;`**: Holds the numeric rating given in the review.

These attributes are all you need to start storing book reviews in your Chromia app.

Written for this site from Chromia’s public course. Code samples are the course’s own.

[← Previous**Part 2: Add a related entity**](https://chromia.com/learn/book-review/book-review-entity/)[Next →**Add an operation for creating book reviews**](https://chromia.com/learn/book-review/book-review-entity/basic-operations/)

On this page

* [Adding the book review entity](#adding-the-book-review-entity)
