# ERP - Edit stocks

**URL:** <https://community.glideapps.com/t/erp-edit-stocks/77731>\
**Category:** Ask for Help\
**Created:** [November 7, 2024, 5:33pm UTC](https://community.glideapps.com/t/erp-edit-stocks/77731 "2024-11-07T17:33:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidoctavio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/davidoctavio/32/80784_2.png) [@davidoctavio](https://community.glideapps.com/u/davidoctavio)\
**Post date:** [November 7, 2024, 5:33pm UTC](https://community.glideapps.com/t/erp-edit-stocks/77731/1 "2024-11-07T17:33:15Z")

</div>

Hello,

I’m contacting you because I want to use Glide to build an ERP and track my stocks.

I have a project with several tables, including :

MP: A table listing all my raw materials needed to manufacture my products.  
PI: A table listing my assembled products (so PI = an association of several MPs).  
ACC: A table listing the accessories that go with my products (power supplies, instructions, etc.)  
PF: A table listing the final SKUs (with associated EANs). A final SKU characterises an assembled product packaged with its accessories (so PF = PI + several ACCs).

In each of these tables, a row represents each item (so each ACC row represents an accessory), and the columns represent the quantities for each accessory, for example.

I have several PIs, with different MPs for each PI.

I’m looking to trigger production:

→ If I trigger a production run of 20 PI parts, this should therefore remove 20 parts from each MP associated with my PI (the MPs are associated by relationships with the PIs so, for example, the MP contains a relevant PI column) and add 20 PIs (from the product I’ve just assembled).

I can’t carry out this type of operation.

It’s quite simple to create an action that increments 20 POIs; actions with Increment numbers make it easy.

However, I can’t manage to count down the 20 MP.

My prediction is that the relationship that associates my PI with my MPs is a multiple relationship (because I need several MPs to make a PI). If I change my relationship column to a simple relationship, I will be able to use the Increment Numbers, but that does not do what I need.

I made a small diagram if it can make it easier to understand. I think this use case could apply to a lot of people, so I tried to clarify this as best as possible.

 ![Support_GLIDE](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/b/ab072b1585c1c02c7faac2104a8d56ad83be77da.jpeg)

Do you have a solution to this please?

---

<div class="post-metadata">

**Author:** ![nathanaelb](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nathanaelb/32/43079_2.png) [@nathanaelb](https://community.glideapps.com/u/nathanaelb)\
**Post date:** [November 7, 2024, 5:49pm UTC](https://community.glideapps.com/t/erp-edit-stocks/77731/2 "2024-11-07T17:49:37Z")

</div>

A raw material can be used in many finished products. And a finished product can used multiple raw materials. This is a many-to-many relationship and this relationship has attributes, namely quantity. I think I would use a join table MP-PI alongside your MP and PI tables to represent this in your database architecture.

Same goes for the relationships between PF and PI, and then PF and ACC. I feel like these are many-to-many relationships that might need attributes, and you would therefore benefit from join tables.

I would work with row IDs of course. The many-to-many relations would be created in the join tables.

I can’t really see much further than that, but that’s how I would start.

---

<div class="post-metadata">

**Author:** ![davidoctavio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/davidoctavio/32/80784_2.png) [@davidoctavio](https://community.glideapps.com/u/davidoctavio)\
**Post date:** [November 7, 2024, 5:52pm UTC](https://community.glideapps.com/t/erp-edit-stocks/77731/3 "2024-11-07T17:52:06Z")

</div>

Thanks Nathan.

I have indeed associated relationships between my tables, but what would be the advantage of having a dedicated table that performs relationships such as MP-PI?  
My main problem is related to the counting of raw materials when manufacturing several units of a single PI. How can this improve my problem?

---

<div class="post-metadata">

**Author:** ![nathanaelb](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nathanaelb/32/43079_2.png) [@nathanaelb](https://community.glideapps.com/u/nathanaelb)\
**Post date:** [November 7, 2024, 5:59pm UTC](https://community.glideapps.com/t/erp-edit-stocks/77731/4 "2024-11-07T17:59:42Z")

</div>

First, I find join tables useful for many-to-many relations. I find the relation easier to visualize and I dislike having CSVs of children in the parent table.

Second, when a relation needs needs further attributes, like a date or quantity that describes the relation, the join table is a good way to do it.

According to AI:  
(notice “When to use”)

| Aspect | Simple Relation | Join Table |
| --- | --- | --- |
| Definition | Direct link between two tables | Separate table to connect two or more tables |
| Usage | One-to-one or one-to-many relationships | Many-to-many relationships |
| Structure | Foreign key in child table | Contains foreign keys from both related tables |
| Data Redundancy | Lower | Higher |
| Flexibility | Less flexible | More flexible for complex relationships |
| Performance | Generally faster for simple queries | Can be slower due to additional joins |
| When to Use | - Direct associations between entities  
- When one entity belongs to another  
- Hierarchical data structures | - When items in one table can relate to multiple items in another table and vice versa  
- Complex relationships between multiple entities  
- When relationship itself has attributes |
| Examples | - User profile linked to user account  
- Blog post linked to author | - Students enrolled in multiple courses  
- Products belonging to multiple categories |

---

<div class="post-metadata">

**Author:** ![davidoctavio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/davidoctavio/32/80784_2.png) [@davidoctavio](https://community.glideapps.com/u/davidoctavio)\
**Post date:** [November 7, 2024, 6:09pm UTC](https://community.glideapps.com/t/erp-edit-stocks/77731/5 "2024-11-07T18:09:57Z")

</div>

Great, thanks!

Would you have any videos to recommend on the subject? I don’t see anything on YouTube about Join Table. I didn’t know anything about this principle or how to set it up, for example.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [November 7, 2024, 11:51pm UTC](https://community.glideapps.com/t/erp-edit-stocks/77731/6 "2024-11-07T23:51:26Z")

</div>

> [@davidoctavio](#):
>
> If I trigger a production run of 20 PI parts, this should therefore remove 20 parts from each MP associated with my PI (the MPs are associated by relationships with the PIs so, for example, the MP contains a relevant PI column) and add 20 PIs (from the product I’ve just assembled).

Is this always 20 though? Like are there any cases that one PI would require 2+ MPs?

Do you need to reduce the related ACC rows as well?

---

<div class="post-metadata">

**Author:** ![MartinMolina](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/martinmolina/32/79822_2.png) [@MartinMolina](https://community.glideapps.com/u/MartinMolina)\
**Post date:** [November 8, 2024, 12:11am UTC](https://community.glideapps.com/t/erp-edit-stocks/77731/7 "2024-11-08T00:11:23Z")

</div>

@davidoctavio - Interesting project! I’m in something similar where I require many-to-many relationships between machines and spare parts!  
I will continue to pay attention to the recommendations of the experts!

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [November 8, 2024, 1:39am UTC](https://community.glideapps.com/t/erp-edit-stocks/77731/8 "2024-11-08T01:39:45Z")

</div>

> [@davidoctavio](#):
>
> Would you have any videos to recommend on the subject?

This one is excellent.

[![](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/d/0d0e4c5eb656cb7f916d9a438ad13f15c10f45cd.jpeg "Learn Database Normalization - 1NF, 2NF, 3NF, 4NF, 5NF") ](https://www.youtube.com/watch?v=GFQaEYEc8_8)
