# Help understanding Campaign Schema/Data Structure?

**URL:** <https://forum.mautic.org/t/help-understanding-campaign-schema-data-structure/30339>\
**Category:** General Discussion\
**Created:** [December 28, 2023, 9:41pm UTC](https://forum.mautic.org/t/help-understanding-campaign-schema-data-structure/30339 "2023-12-28T21:41:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![oguruma](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/oguruma/32/1003_2.png) [@oguruma](https://forum.mautic.org/u/oguruma)\
**Post date:** [December 28, 2023, 9:41pm UTC](https://forum.mautic.org/t/help-understanding-campaign-schema-data-structure/30339/1 "2023-12-28T21:41:52Z")

</div>

I’m looking to build a Mautic integration with ERPNext (an open source ERP/CRM).

I’m trying to get help understanding the general structure of how Mautic Campaigns are stored in the database.

Can somebody give me a general breakdown of how this data is stored?

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [December 29, 2023, 6:45am UTC](https://forum.mautic.org/t/help-understanding-campaign-schema-data-structure/30339/2 "2023-12-29T06:45:21Z")

</div>

Look at these tables, and you’ll get it right away:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/3/348e3a8836a98448ae37df56c7beb3e3cac5922c.png)

---

<div class="post-metadata">

**Author:** ![oguruma](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/oguruma/32/1003_2.png) [@oguruma](https://forum.mautic.org/u/oguruma)\
**Post date:** [December 29, 2023, 9:10pm UTC](https://forum.mautic.org/t/help-understanding-campaign-schema-data-structure/30339/3 "2023-12-29T21:10:41Z")

</div>

Thanks for the input.

Just to make sure I’m understanding this right:  
campaigns defines basic info about the campaign  
campaign\_events is the list of events in a particular campaign  
campaign\_leads is the junction table - campaign to leads  
campaign\_leadlist\_xref is the junction table - campaigns to leadlist  
lead\_list is a list of leads (Contacts)  
lead\_list\_leads is the junction table - lead\_lists\_leads  
campaign\_lead\_event\_log is basically the “assignment” of an event to a lead

Assuming my general understanding of this is correct, how is the campaign\_lead\_event\_log kept from growing too large? I’d imagine if you had tens of thousands of leads and several campaigns with lots of actions, then that table would grow very quickly. Are old events purged at any point?

Also, since Campaigns have decisions, actions, and conditions, are all 3 of them stored in campaign\_events?

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [December 30, 2023, 10:58am UTC](https://forum.mautic.org/t/help-understanding-campaign-schema-data-structure/30339/4 "2023-12-30T10:58:13Z")

</div>

> Assuming my general understanding of this is correct, how is the campaign\_lead\_event\_log kept from growing too large? I’d imagine if you had tens of thousands of leads and several campaigns with lots of actions, then that table would grow very quickly. Are old events purged at any point?

Depends on the size of your operation and your definition of ‘large’ and ‘quickly’.

If you run a lot of campaigns for a lot of contacts, then you need a larger db and a faster server. Mautic takes 10x more DB space then Mailwizz for example, and 30x more then Sendy. But it’s 100x more capable, so it’s a good tradeoff.

You can also clean stuff:

> **[GitHub - Leuchtfeuer/mautic-housekeeping-bundle](https://github.com/Leuchtfeuer/mautic-housekeeping-bundle)**
>
> Contribute to Leuchtfeuer/mautic-housekeeping-bundle development by creating an account on GitHub.

Again it depends what you do with Mautic, but it’s not rare to have 3-5GB DB for a smaller install with 1000 contacts and 80-120GB for 250k contacts.

I do very brital cleaning sometimes. Here is a tutorial, where I show you some sql commands and results:

> **[The great Mautic weight control – Joey Keller](https://joeykeller.com/the-great-mautic-weight-control/)**
