Mohan
Mohan

Reputation: 11

Modelling Cassandra from XML & C#

I am very beginner to Cassandra. I am finding it difficult to model the XML file attached.

My requirement is:

  1. I get many XML files as given below on daily basis. I need to write a C# program to read the XML and store in Cassandra.
  2. Once stored, the data would be read by 1000's of customers 1000's of times. Once the data is stored, it would NOT be updated again.

NOTE: It is possible that each parent node (Ex: Customer/Site...) may appear more no. of times. i.e i may have Customer2, Site2, another EquipmentDetails node etc.

My XML:

<?xml version="1.0" standalone="yes"?>
<MyAnalystXMLReport>
  <MC-DomainID ID="XYZ123">
    <Customer Name="CUSTOMER1" ID="53043">
      <Site Name="SITE1" ID="488688">
        <EquipmentDetails>
          <EquipmentDescription>Test Desc</EquipmentDescription>
          <EquipmentRefId>T3567111</EquipmentRefId>
          <ComponentDescription>COM Oil</ComponentDescription>
          <ComponentRefId>
          </ComponentRefId>
          <AnanlystNo>1235LKJU</AnanlystNo>
          <ComponentType>TestComp</ComponentType>
          <Sample SampleNo="976023696">
            <SampleCondition>USUAL</SampleCondition>
            <AnalysisComments>Test Comments</AnalysisComments>
            <DateRecieved>2015-12-10</DateRecieved>
            <DateAnalysed>2015-12-18</DateAnalysed>
            <EquipmentLife>
            </EquipmentLife>
            <LubricantLife>
            </LubricantLife>
            <TopUpVolume>0</TopUpVolume>
            <FuelUsed>
            </FuelUsed>
            <Tests>
              <TestGroup Name="Group NAME1" ID="667">
                <Test Name="Test Name1" ID="1785">
                  <Result>171.3</Result>
                </Test>
              </TestGroup>
              <TestGroup Name="Group NAME2" ID="617">
                <Test Name="Test NAME2" ID="1763">
                  <Result>153.40</Result>
                </Test>
              </TestGroup>
            </Tests>
          </Sample>
        </EquipmentDetails>
      </Site>
    </Customer>
  </MC-DomainID>
</MyAnalystXMLReport>

How would i model this XML in efficient way to achieve this requirement? And what is the easiest way to store this data data & model in Cassandra using C#. Any example would be greatly appreciated.

Thanks for your help.

Upvotes: 0

Views: 266

Answers (1)

bechbd
bechbd

Reputation: 6341

So to begin, modelling data for use in Cassandra is a bit different than a traditional RDBMS. My first suggestion would be to look at this link:

http://www.datastax.com/dev/blog/basic-rules-of-cassandra-data-modeling

Basically Cassandra using a table-per-query methodology to determine the data models. This means that you need to know how your application will query the data and then model your logical and physical persistance models after that. DataStax has some excellent tutorial videos on Cassandra in general and Data modelling specifically. See here:

https://academy.datastax.com/courses/ds220-data-modeling

As far as how to use it from C#, there is a good video on how to get started using c# here:

https://academy.datastax.com/demos/getting-started-apache-cassandra-and-c-net

Upvotes: 2

Related Questions