# Smart Relationship - reference key

**URL:** <https://community.forestadmin.com/t/smart-relationship-reference-key/3746>\
**Category:** Help me!\
**Created:** [November 21, 2021, 10:24pm UTC](https://community.forestadmin.com/t/smart-relationship-reference-key/3746 "2021-11-21T22:24:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vaclav](https://avatars.discourse-cdn.com/v4/letter/v/34f0e0/32.png) [@Vaclav](https://community.forestadmin.com/u/Vaclav)\
**Post date:** [November 21, 2021, 10:24pm UTC](https://community.forestadmin.com/t/smart-relationship-reference-key/3746/1 "2021-11-21T22:24:21Z")

</div>

Hello,  
I am trying out your smart relationships right now. I managed that somehow, but in general, I am not pretty sure how to deal with `reference` key.

I found just one sentence about that:

`A HasMany Smart Relationship is created like a Smart Field with the reference option to indicates on which collection the Smart Relationship points to. `

> **[Create a Smart relationship](https://docs.forestadmin.com/documentation/reference-guide/relationships/create-a-smart-relationship)**

I can imagine that it is a reference to that related table, but what exactly should be there please?

- Model name?
- Table name?
- Is that necessary for generated url?
- For what is this indication necessary?
- In your example, you have `reference: 'customers.id'`, could it be also without id? Could be there customers.name for example, please?

I mean, I can blindly follow that example and put there xy.id every time, I just don’t know exactly what are the implications of that.

Thank you very much clarification.

Best regards,

Vaclav

---

<div class="post-metadata">

**Author:** ![Arnaud\_Moncel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arnaud_moncel/32/24_2.png) [@Arnaud\_Moncel](https://community.forestadmin.com/u/Arnaud_Moncel)\
**Post date:** [November 22, 2021, 11:14am UTC](https://community.forestadmin.com/t/smart-relationship-reference-key/3746/2 "2021-11-22T11:14:12Z")

</div>

Hi @Vaclav 👋 The reference options is used to differentiate a “classic” smart field from a “relationship” smart field.  
This reference is the collection name of the wanted relationship.  
This is not used for generated url but it is used to adapt the UI.  
In the case of hasmany relation ship you not necessarily need to write `.id` the most important thing is the reference collection name.  
Let me know if that help 🙏

---

<div class="post-metadata">

**Author:** ![Vaclav](https://avatars.discourse-cdn.com/v4/letter/v/34f0e0/32.png) [@Vaclav](https://community.forestadmin.com/u/Vaclav)\
**Post date:** [November 25, 2021, 8:55am UTC](https://community.forestadmin.com/t/smart-relationship-reference-key/3746/3 "2021-11-25T08:55:22Z")

</div>

Hi @Arnaud_Moncel,  
thank you for the explanation. I would have one more question please.  
What if I want to have a table with three or four tables? E.g.:

- Customers
- Orders
- Products in order

Should I reference just “Orders” or both “Orders and Products” in array or something?

Thank for your help,

Vaclav

---

<div class="post-metadata">

**Author:** ![Arnaud\_Moncel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arnaud_moncel/32/24_2.png) [@Arnaud\_Moncel](https://community.forestadmin.com/u/Arnaud_Moncel)\
**Post date:** [November 25, 2021, 10:42am UTC](https://community.forestadmin.com/t/smart-relationship-reference-key/3746/4 "2021-11-25T10:42:55Z")

</div>

If i understand well your question, you want to have four smart relationship linked to your main collection.  
So you need to define, in your `forest/yourmaincollection.js`, four smart relationship fields.  
And after that you need to create the four related route like `router.get('/yourmaincollection/:yourmaincollection_id/relationships/firstrelationships',...`.  
I dont know if it’s clear, let me know.
