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
entity
keyword: Defines a new entity, similar to creating a table in a database.- Attributes:
key isbn: text
: Setsisbn
as the unique identifier for each book. Thekey
keyword ensures uniqueness andtext
specifies that theisbn
is stored as text.title: text
andauthor: text
: Define thetitle
andauthor
attributes, both stored as text.
With the Book
entity defined, you can now use it in your decentralized application.