# Relationships in Rell explained · Learn Chromia

> This course covers data modelling in Rell, with a focus on defining relationships between entities. You will learn how table relationships work in Rell and…

Source: https://chromia.com/learn/relationships-course/introduction/

Relationships in Rell explainedLesson 1 of 6

1. [01Relationships in Rell explained](https://chromia.com/learn/relationships-course/introduction/)
2. [02Creating Records](https://chromia.com/learn/relationships-course/joins/)
3. [03Many-to-many relationships](https://chromia.com/learn/relationships-course/many-to-many/)
4. [04One-to-many relationships](https://chromia.com/learn/relationships-course/one-to-many/)
5. [05One-to-one relationship](https://chromia.com/learn/relationships-course/one-to-one/)
6. [06Set up your project](https://chromia.com/learn/relationships-course/setup/)

[Learn](https://chromia.com/learn/)[Relationships in Rell explained](https://chromia.com/learn/relationships-course/)

01 / 06

# Relationships in Rell explained

This course covers data modelling in Rell, with a focus on defining relationships between entities. You will learn how table relationships work in Rell and how to apply them when building efficient, scalable applications.

You should already be comfortable with SQL basics, including table relationships and joins. The course maps those concepts onto Rell so you can reuse what you know from SQL to design solid, scalable data models.

After finishing, you will be able to model data in Rell and structure the data layer of more advanced applications efficiently.

### What you will learn

You will implement three kinds of relationships in Rell:

* **One-to-one**
* **One-to-many**
* **Many-to-many**

You will see how to create each relationship and use it in a working application. You will also work with two kinds of joins:

* **Inner Join**
* **Outer Join**

### Application concept and structure

Throughout the course, you will build a library management application around these core entities:

* **Library**: Details about the library, including its address and shelves.
* **Shelf**: The shelf number and the books stored on it.
* **Book**: The book's title, its authors, and its reviews.
* **Author**: The author's name and the books they wrote.
* **Member**: The member's name and the books they borrowed.
* **Loan**: A record of a borrowed book, with its loan and return dates.

### Implementation details

1. **One-to-one relationship**
   * **Library - address**: Every library has exactly one address.
2. **One-to-many relationship**
   * **Library - shelves**: One library can contain many shelves.
   * **Shelf - books**: One shelf can store many books.
3. **Many-to-many relationship**
   * **Book - authors**: One book can have several authors, and one author can write several books.
   * **Member - loans**: Through loans, one member can borrow many books, and one book can be borrowed by many members.

### Advantages of Rell

* **Simplicity**: Rell has a clean, approachable syntax. You declare relationships directly instead of dealing with the details of foreign keys and constraints.
* **Readability**: Rell code is easier to read and maintain, so you can grasp your database structure quickly.
* **Error reduction**: Because Rell handles keys and constraints for you rather than requiring manual management, your database design is less prone to errors and inconsistencies.

### Related materials

The course builds on the documentation below. Refer to it for background on the concepts and techniques used:

| Section | Type | Documentation |
| --- | --- | --- |
| Rell | Entity | [Entity](https://docs.chromia.com/rell/language-features/modules/entity) |
| Rell | Relationships | [One-to-one](https://docs.chromia.com/rell/language-features/modules/entity#one-to-one) |
| Rell | Relationships | [One-to-many](https://docs.chromia.com/rell/language-features/modules/entity#one-to-many) |
| Rell | Relationships | [Many-to-many](https://docs.chromia.com/rell/language-features/modules/entity#many-to-many) |
| Rell | Joins | [Inner joins](https://docs.chromia.com/rell/language-features/database/overview#inner-join) |
| Rell | Joins | [Outer joins](https://docs.chromia.com/rell/language-features/database/overview#outer-join) |

### Repository link

You can find the full source code for this course in the
[relationships course repository](https://bitbucket.org/chromawallet/relational-course).

### What's next?

The upcoming lessons look at each entity and its relationships in depth. You will define these relationships in Rell and run various operations on the records. When you reach the end, you will have a complete library management application that shows how relational database relationships work in practice.

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

[← Course**Relationships in Rell explained**](https://chromia.com/learn/relationships-course/)[Next →**Creating Records**](https://chromia.com/learn/relationships-course/joins/)
