Create your first entity
In this section, we'll define the Book entity using Rell. This will allow us to manage book data and perform queries
on it.
Define the Book entity
In Rell, entities are similar to tables in relational databases. We'll create a Book entity to manage the book
information.
Entity diagram
Add the entity definition
Open the src/main/entities.rell file and insert the following Rell code:
src/main/entities.rell
entity book {
key isbn: text;
title: text;
author: text;
}
Code explanation
entitykeyword: This keyword defines a new entity, similar to creating a table in a database.- Attributes:
key isbn: text: This specifiesisbnas the unique identifier for each book. Thekeykeyword ensures that the value is unique and creates an index on this field, which improves query performance. Thetexttype indicates that the value will be stored as a string.title: textandauthor: text: These attributes define the book's title and author, both stored as text.
With the Book entity defined, you can now utilize it in your decentralized application.