# Take snapshot every day of Mysql datatbase in ElasticSearch

**URL:** <https://discuss.elastic.co/t/take-snapshot-every-day-of-mysql-datatbase-in-elasticsearch/220609>\
**Category:** Elasticsearch\
**Created:** [February 24, 2020, 9:29am UTC](https://discuss.elastic.co/t/take-snapshot-every-day-of-mysql-datatbase-in-elasticsearch/220609 "2020-02-24T09:29:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anujeet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anujeet/32/45644_2.png) [@anujeet](https://discuss.elastic.co/u/anujeet)\
**Post date:** [February 24, 2020, 9:29am UTC](https://discuss.elastic.co/t/take-snapshot-every-day-of-mysql-datatbase-in-elasticsearch/220609/1 "2020-02-24T09:29:32Z")

</div>

Hello.

I have a Mysql application. But we want to do some analysis on the data that is being stored. In the Mysql database, the data is being overriden everyday. But we want to store everyday's dump in ElasticSearch so that we can use that data for plotting graphs or do anamolies detection.

Right now, I am not sure about which data model technique I should use to migrate the data.  
There are two approaches so far:

- application joins:  
Vehicle  
a  
b  
c  
ownershipTYpeId : 1  
vehicleTypeId: 2  
companyId: 1

VehicleTYe  
id  
name

ownershipTYpe  
id  
name

company  
id  
name

Which means I will create an index Vehicle, and store ids in it just like the RDBMS structure.  
But here if I want to search instead of id field, I have to run separate queries for fetch id for each relation.

Another approach is:

Denormalization:  
Vehicle  
a  
b  
c  
ownershipTYpe : {  
id: 1  
name: abc  
}

I will store the data of the relational entities in the form of an object in the Vehicle index.  
I am not sure which approach will be better for graph plotting and other analysis in the future.

Does anyone has any experiences in this topic?

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![Dominic\_Page](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dominic_page/32/48318_2.png) [@Dominic\_Page](https://discuss.elastic.co/u/Dominic_Page)\
**Post date:** [March 6, 2020, 2:55pm UTC](https://discuss.elastic.co/t/take-snapshot-every-day-of-mysql-datatbase-in-elasticsearch/220609/2 "2020-03-06T14:55:56Z")

</div>

Hi @Anujeet,

My first attempt would be to Denormalize the data, then you can do a single query.

If all of your entries are updated every day, you might consider creating a daily index

Hope this helps!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 3, 2020, 2:55pm UTC](https://discuss.elastic.co/t/take-snapshot-every-day-of-mysql-datatbase-in-elasticsearch/220609/3 "2020-04-03T14:55:57Z")

</div>

Closed on April 3, 2020, 2:55pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
