# Code the model in Rell · A simple Chromia app with Rell and React · Learn Chromia

> Chromia uses Rell to define the blockchain's data model. The Rell code for this model appears below, and the sections that follow explain each part.

Source: https://chromia.com/learn/my-news-feed/module-one/data-modeling/model/

A simple Chromia app with Rell and ReactLesson 6 of 27

1. [01Building a simple Chromia app with Rell, React and FT4](https://chromia.com/learn/my-news-feed/introduction/)
2. [02Project setup complete](https://chromia.com/learn/my-news-feed/setup/)

Module 1: A Rell backend with FT accounts

1. [03Overview](https://chromia.com/learn/my-news-feed/module-one/)
2. [04Part 1: Designing the database schema](https://chromia.com/learn/my-news-feed/module-one/data-modeling/)
3. [05The data model](https://chromia.com/learn/my-news-feed/module-one/data-modeling/tables/)
4. [06Code the model in Rell](https://chromia.com/learn/my-news-feed/module-one/data-modeling/model/)
5. [07Part 2: Set up accounts](https://chromia.com/learn/my-news-feed/module-one/create-accounts/)
6. [08FT4 accounts configuration](https://chromia.com/learn/my-news-feed/module-one/create-accounts/install-configure-ft4/)
7. [09Authentication with FT4 accounts](https://chromia.com/learn/my-news-feed/module-one/create-accounts/authentication/)
8. [10Part 3: A closer look at operations and queries](https://chromia.com/learn/my-news-feed/module-one/operations-queries/)
9. [11Basic operations](https://chromia.com/learn/my-news-feed/module-one/operations-queries/basic-operations/)
10. [12Basic queries](https://chromia.com/learn/my-news-feed/module-one/operations-queries/write-queries/)
11. [13Part 4: Validating and verifying input](https://chromia.com/learn/my-news-feed/module-one/input-verification/)
12. [14Verify inputs](https://chromia.com/learn/my-news-feed/module-one/input-verification/input-verification/)
13. [15Run unit tests](https://chromia.com/learn/my-news-feed/module-one/input-verification/tests/)
14. [16Part 5: How the dapp project is organized](https://chromia.com/learn/my-news-feed/module-one/project-structure/)
15. [17Work with Rell modules](https://chromia.com/learn/my-news-feed/module-one/project-structure/modules/)
16. [18Add modules to your dapp](https://chromia.com/learn/my-news-feed/module-one/project-structure/incorporate-modules/)
17. [19Part 6: Sign up users with an EVM wallet](https://chromia.com/learn/my-news-feed/module-one/register-evm-accounts/)
18. [20Sign up accounts with EVM wallets](https://chromia.com/learn/my-news-feed/module-one/register-evm-accounts/register-evm-accounts/)
19. [21Test the registration](https://chromia.com/learn/my-news-feed/module-one/register-evm-accounts/test-registration/)

Module 2: The React project

1. [22Overview](https://chromia.com/learn/my-news-feed/module-two/)
2. [23Set up the project](https://chromia.com/learn/my-news-feed/module-two/setup/)
3. [24Project scaffold](https://chromia.com/learn/my-news-feed/module-two/scaffold/)
4. [25Connect the client](https://chromia.com/learn/my-news-feed/module-two/connecting-the-client/)
5. [26Summary and manual testing](https://chromia.com/learn/my-news-feed/module-two/summary-and-tests/)

1. [27What is next?](https://chromia.com/learn/my-news-feed/what-next/)

[Learn](https://chromia.com/learn/)[A simple Chromia app with Rell and React](https://chromia.com/learn/my-news-feed/)

06 / 27Module 1: A Rell backend with FT accountsBeginner

# Code the model in Rell

Chromia uses Rell to define the blockchain's data model. The Rell code for this model appears below, and the sections that follow explain each part.

src/news\_feed/model.rell

```
entity user {
  mutable name;
  key id: byte_array;
}

entity follower {
  index user;
  index follower: user;
  key user, follower;
}

entity post {
  timestamp = op_context.last_block_time;
  index user;
  content: text;
}
```

### User entity

The `user` entity works like a database table with two fields, `name` and `id`. Because `name` is declared mutable, you can change its value later. The `id` field is declared as a key, which makes its value unique across all records of the entity. One more detail:

* The type of `name` is `text`.

### Follower entity

The `follower` entity records that one user follows another. Its fields are:

* `index user;`: References the `user` entity. Since one user can have many followers, this forms a one-to-many relationship. Indexing the field makes SQL queries on it faster.
* `index follower: user;`: A second field, called "follower", that holds the user following the user in the first field. It is also indexed so queries stay fast.
* `key user, follower;`: A composite key that prevents a user from following the same user more than once, keeping each follower relationship unique.

### Post entity

The `post` entity stores a single post on your social media platform. It contains:

* `timestamp = op_context.last_block_time;`: Holds the post's timestamp. Its type is inferred as `integer`, and its default value is the creation time of the last known block, so your code never has to set it explicitly.
* `index user;`: Points to the user who wrote the post. The index speeds up lookups.
* `content: text;`: Holds the text of the post in the `content` field.

You now have a basic Rell database model for a social media platform on the Chromia blockchain. It stores users, their posts, and who follows whom, which gives you the foundation for building the rest of your decentralized app on Chromia.

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

[← Previous**The data model**](https://chromia.com/learn/my-news-feed/module-one/data-modeling/tables/)[Next →**Part 2: Set up accounts**](https://chromia.com/learn/my-news-feed/module-one/create-accounts/)
