# Efficient data storage and querying for production entries every 30 minutes

**URL:** <https://forum.inductiveautomation.com/t/efficient-data-storage-and-querying-for-production-entries-every-30-minutes/70528>\
**Category:** Ignition\
**Tags:** perspective, ignition81, scripting, database\
**Created:** [March 2, 2023, 1:58pm UTC](https://forum.inductiveautomation.com/t/efficient-data-storage-and-querying-for-production-entries-every-30-minutes/70528 "2023-03-02T13:58:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mariano\_Alvarez](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mariano_alvarez/32/35283_2.png) [@Mariano\_Alvarez](https://forum.inductiveautomation.com/u/Mariano_Alvarez)\
**Post date:** [March 2, 2023, 1:58pm UTC](https://forum.inductiveautomation.com/t/efficient-data-storage-and-querying-for-production-entries-every-30-minutes/70528/1 "2023-03-02T13:58:11Z")

</div>

I am working on a project where I need to store quality check data in a database for production purposes, we are changing from paper forms to an Ignition perspective application.  
Each check consists of 16 tests, the datetime value (time interval integer) and work order , besides some additional information. The checks need to be recorded every 30 minutes, but I would like to store the data in a compact way so that it can be easily queried and analyzed later. Additionally, I am looking for advice on the best way to store and query the data for a single shift (8 hours), rather than having a new entry for each 30-minute interval.  
here is an example of how the current structure looks like

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/4/b4d1ae441009858af3f57781903e74e185b4aa5b.png)

Any suggestions on how to efficiently store and query this data would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 2, 2023, 2:02pm UTC](https://forum.inductiveautomation.com/t/efficient-data-storage-and-querying-for-production-entries-every-30-minutes/70528/2 "2023-03-02T14:02:06Z")

</div>

That's not much data. I recommend storing each check separately, with enough ancillary information to audit it later (as needed). Use a PIVOT to make the 16 half-hour columns when querying.

---

<div class="post-metadata">

**Author:** ![Mariano\_Alvarez](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mariano_alvarez/32/35283_2.png) [@Mariano\_Alvarez](https://forum.inductiveautomation.com/u/Mariano_Alvarez)\
**Post date:** [March 2, 2023, 2:08pm UTC](https://forum.inductiveautomation.com/t/efficient-data-storage-and-querying-for-production-entries-every-30-minutes/70528/3 "2023-03-02T14:08:01Z")

</div>

I forgot to mention that this will be running on approx. 30-40 machines. Should I create a table for every instance?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 2, 2023, 2:09pm UTC](https://forum.inductiveautomation.com/t/efficient-data-storage-and-querying-for-production-entries-every-30-minutes/70528/4 "2023-03-02T14:09:52Z")

</div>

No, include a machine ID column in the one table.

---

<div class="post-metadata">

**Author:** ![Mariano\_Alvarez](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mariano_alvarez/32/35283_2.png) [@Mariano\_Alvarez](https://forum.inductiveautomation.com/u/Mariano_Alvarez)\
**Post date:** [March 2, 2023, 3:09pm UTC](https://forum.inductiveautomation.com/t/efficient-data-storage-and-querying-for-production-entries-every-30-minutes/70528/5 "2023-03-02T15:09:14Z")

</div>

Should I make a column for machine name and one for machine number? or one for machine ID and use a dictionary?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 2, 2023, 3:21pm UTC](https://forum.inductiveautomation.com/t/efficient-data-storage-and-querying-for-production-entries-every-30-minutes/70528/6 "2023-03-02T15:21:00Z")

</div>

I would make a column just for a machine ID. Use a separate table holding machine ID & Name combinations, with ID as its primary key. You can then include name in queries using a join.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [March 2, 2023, 3:55pm UTC](https://forum.inductiveautomation.com/t/efficient-data-storage-and-querying-for-production-entries-every-30-minutes/70528/7 "2023-03-02T15:55:11Z")

</div>

I would recommend reading up on normalization in the context of databases, there's not much to it and it will help you design cleaner databases that are easier to work with.
