# Ordering in Relations, and Separate Relations

**URL:** <https://community.fibery.io/t/ordering-in-relations-and-separate-relations/4926>\
**Category:** Get Help\
**Created:** [August 8, 2023, 5:09pm UTC](https://community.fibery.io/t/ordering-in-relations-and-separate-relations/4926 "2023-08-08T17:09:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Charles\_Lee](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/charles_lee/32/7332_2.png) [@Charles\_Lee](https://community.fibery.io/u/Charles_Lee)\
**Post date:** [August 8, 2023, 5:09pm UTC](https://community.fibery.io/t/ordering-in-relations-and-separate-relations/4926/1 "2023-08-08T17:09:43Z")

</div>

Two questions.

I am trying to use Fibery as a basic CMS. I am planning some courses, that each have lessons. The lessons need an order.

1. I can put a # field called Order. Is there a way to enforce uniqueness, so I don’t accidentally put the same number twice? Or is there a simple way to define the order of the relation, so I don’t need to type each number? Imagine I decide to add another exercise to the beginning of a 100 lesson course, then I have to basically change every number after it manually (or I guess I could make it -1, but then I’d still have a problem if I wanted to insert something in the middle).

2. If lessons can belong to multiple courses, but another course has the lesson in a different order - do I just need to create a new table, that holds its own order value? Like an intermediate join table?

3. I guess a third question - am I abusing Fibery? Is this all a bad idea?

---

<div class="post-metadata">

**Author:** ![YvetteLans](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/yvettelans/32/6101_2.png) [@YvetteLans](https://community.fibery.io/u/YvetteLans)\
**Post date:** [August 8, 2023, 5:41pm UTC](https://community.fibery.io/t/ordering-in-relations-and-separate-relations/4926/2 "2023-08-08T17:41:16Z")

</div>

> [@Charles\_Lee](#):
>
> I guess a third question - am I abusing Fibery? Is this all a bad idea?

I think it’s a real good idea 😃 The beauty of Fibery is that is super flexible and that you can create workarounds when needed.

When you use list view (or the new [experimental new grid view!](https://community.fibery.io/t/july-20-2023-experimental-new-grid-view-and-columns-layout-in-docs/4818/32)) you can change the order of items when you drag & drop.

For your situation:

- Link the lessons to the applicable course(s)
- Create a list/grid view per course.
  - Level 1: course / Level 2: lessons.

- Create a separate view for course A and a view for course B.
  - Use filter to only show the lessons that belong to course A or B.

- Order the lessons in each view via drag & drop

Only thing to be aware of is that you can’t use any other sorting (like date or name) when you manually want to sort them 🙂

---

<div class="post-metadata">

**Author:** ![Charles\_Lee](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/charles_lee/32/7332_2.png) [@Charles\_Lee](https://community.fibery.io/u/Charles_Lee)\
**Post date:** [August 8, 2023, 6:07pm UTC](https://community.fibery.io/t/ordering-in-relations-and-separate-relations/4926/3 "2023-08-08T18:07:47Z")

</div>

Oh man I saw that you guys responded super quickly to posts, but somehow I never thought that would happen to me. Thank you!

I think I get it. Great. I’m still a little fuzzy on exactly how I’d resolve everything via API. Perhaps a naming convention for each view, but I’ll cross that bridge when I get there. This works great for now, I wasn’t using the “view” abstraction at all.

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [August 8, 2023, 6:17pm UTC](https://community.fibery.io/t/ordering-in-relations-and-separate-relations/4926/4 "2023-08-08T18:17:48Z")

</div>

I’ll just add that Fibery does not natively offer validation on data e.g. enforcing that a field value must be Unique (different to all existing values).  
However, every entity has a public ID which is a string of numbers which will be unique (for all entities of the same type).  
So if you have several Tasks, they might have public IDs 1, 2 and 3. No other Task created in the future will use any of these values. Even if the Task with public ID of 2 is deleted, no other Task will get public ID of 2.

If you need ordering of items, but based on their relation to another type, e.g. ordering of Tasks that belong to a given Project, then there are a few options, but the optimal option to choose largely depends on what your ultimate purpose is.

---

<div class="post-metadata">

**Author:** ![njyo](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/njyo/32/923_2.png) [@njyo](https://community.fibery.io/u/njyo)\
**Post date:** [August 11, 2023, 2:35pm UTC](https://community.fibery.io/t/ordering-in-relations-and-separate-relations/4926/5 "2023-08-11T14:35:10Z")

</div>

Hi @Charles_Lee,

If you need to have an actual field that you can sort by (e.g. `Order`) you could consider adding some complexity with a previous/next class relationship. If you have multiple courses, you might need to have multiple previous and next classes, which will make things a little more complex.

Then, you could have two automations:

1. If my reference to the previous class changes, update my order number to `previous + 1` (and `1` in case there is nothing previous)
2. If my order number has changed, update the order number of my follow-on classes to `the max of (mine + 1) and (next + 1)`

Happy Jenga-tower building! 😉
