简体   繁体   中英

Tracking monthly call count per individual - MySQL or XML?

I am trying to determine the best way to store a monthly call tally for around 43 personnel. The client wants to be able to view the data in several different ways - who has the most/least calls YTD, graphs of the top 10, change from the pervious year, etc.

I considered trying to continuously update an XML file for each year with each individual's name and monthly call tally but that would make it more challenging to extract different types of data than if I were to use MySQL.

If MySQL is the favorable choice, would it be best to store the data with a single row per year per person with a column in each for every month of the year? Or, every month, add a row with the year, month, and call tally?

Advice would be appreciated.

Here is a sample of the XML file that contains the data -

<?xml version="1.0" encoding="UTF-8" ?>
<report>
    <ReportHeader>
        <Section SectionNumber="0">
            <Picture Name="DeptPic1" GraphicType="BolbField"></Picture>
        </Section>
    </ReportHeader>
    <Group Level="1">
        <GroupFooter>
            <Section SectionNumber="1">
                <Field Name="Field11" FieldName="{IncdPers.PERSONNAME}">
                    <FormattedValue>Captain John Doe</FormattedValue>
                    <Value>Captain John Doe</Value>
                </Field>
                <Field Name="Field12" FieldName="{IncdPers.PERSONLOOKUPID}">
                    <FormattedValue>Doe, John</FormattedValue>
                    <Value>Doe, John</Value>
                </Field>
                <Field Name="Field13" FieldName="DistinctCount ({In5basic.GUIDIDNUMBER}, {IncdPers.PERSONLOOKUPID})">
                    <FormattedValue>6</FormattedValue>
                    <Value>6</Value>
                </Field>
                <Field Name="Field14" FieldName="{@PercentInc}">
                    <FormattedValue>54.55</FormattedValue>
                    <Value>54.55</Value>
                </Field>
                <Text Name="Text14">
                    <TextValue>%</TextValue>
                </Text>
            </Section>
        </GroupFooter>
    </Group>
    <Group Level="1">
        <GroupFooter>
            <Section SectionNumber="1">
                <Field Name="Field11" FieldName="{IncdPers.PERSONNAME}">
                    <FormattedValue>Firefighter Jane Smith</FormattedValue>
                    <Value>Firefighter Jane Smith</Value>
                </Field>
                <Field Name="Field12" FieldName="{IncdPers.PERSONLOOKUPID}">
                    <FormattedValue>Smith, Jane</FormattedValue>
                    <Value>Smith, Jane</Value>
                </Field>
                <Field Name="Field13" FieldName="DistinctCount ({In5basic.GUIDIDNUMBER}, {IncdPers.PERSONLOOKUPID})">
                    <FormattedValue>1</FormattedValue>
                    <Value>1</Value>
                </Field>
                <Field Name="Field14" FieldName="{@PercentInc}">
                    <FormattedValue>9.09</FormattedValue>
                    <Value>9.09</Value>
                </Field>
                <Text Name="Text14">
                    <TextValue>%</TextValue>
                </Text>
            </Section>
        </GroupFooter>
    </Group>
</report>

This is exactly the kind of thing relational databases are good at. I would store the data at its most granular level - records of individual calls if you have it, if not then per user/month. Having a column for each month will make it difficult to query.

If the data your receive is not raw call data, but some sort of monthly summary, store it in the db that way to give yourself the most flexibility when querying.

I'd have two tables. The first would simply be about the individual making the calls. The second table would be about the calls that person made. Like this:

Table 1
-------
+----------------+
| id        name |
+----------------+
  0         bob
  1         john
  2         mary



Table 2
-------
+----------------------------------------------+
| id        user_id     calls       date       |
+----------------------------------------------+
  0         0           12          2012-10-21
  1         1           15          2012-10-21
  2         2           23          2012-10-21
  3         0           16          2012-10-22
  4         1           17          2012-10-22
  5         2           28          2012-10-22

As you can see, you can use MySQL to store daily call info, or whatever interval you want. You can track numbers in any given time period (the example above shows only 2 days, though), generate reports off those numbers, show trends over time, etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM