Mail: [email protected] Phone: +1(424)231-4091

Crud: Table Relationship

When you create a CRUD component on NexoPOS, you can establish a relationship with existing tables to pull data from them simultaneously

In a concrete example, if you create a CRUD for books, you might want to assign the author (in our case, the person who made the entry, not the book author) or assign it to a category. You can configure the various relationships from your CRUD class: Inner Join, Left Join, or Right Join. The impact on the display depends strictly on the type of relationship you choose.

Inner Join

In this example, as on any database inner join strategy, both resources must exist to provide a result. It might be convenient to show books that have an author or a category that actually exists.

Here, we're defining an Inner Join relationship. We'll assign existing users to the book author. If the user doesn't exist (or has been deleted) the book will not be listed.

Left Join

Alternatively, you might want to give priority to either table. With left Join, the priority is given to the table set on the left part of the relationship. This means that if the entry on the right side doesn't exist, the value will be null, and there will be a result.

With this approach, we have created a left join query on the user's table. If the users don't exist, we will still have an entry for the book. However, all the user information will be set as null.

Right Join

The Right Join method is the opposite of the LeftJoin. In our example, instead of giving priority to the books table, we'll now give priority to the user's table. This means that if the book is missing (or has been deleted), there will still be an entry.