[英]Tracking monthly call count per individual - MySQL or XML?
我正在尝试确定存储大约43名人员的每月电话理货的最佳方式。 客户希望能够以几种不同的方式查看数据-年初至今以来调用次数最多/最少的人,排名前10位的图表,前一年的变化等。
我考虑过尝试每年用每个人的姓名和月度通话记录来不断更新XML文件,但这比使用MySQL来提取不同类型的数据更具挑战性。
如果MySQL是最佳选择,是否最好将数据存储在每人每年每人一行中,并且每年每个月每列中存储一列? 或者,每个月在年份,月份中添加一行,然后调用提示?
意见将不胜感激。
这是包含数据的XML文件的示例-
<?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>
这正是关系数据库最擅长的事情。 我将在最细粒度的级别上存储数据-如果有的话,记录每个呼叫的记录,如果没有,则按用户/月记录。 每个月都有一列将使查询变得困难。
如果您收到的数据不是原始呼叫数据,而是某种形式的月度汇总,请以这种方式将其存储在数据库中,以便在查询时获得最大的灵活性。
我有两张桌子。 第一个只是关于个人拨打电话。 第二张表是关于那个人打的电话。 像这样:
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
如您所见,您可以使用MySQL来存储每日呼叫信息或所需的任何间隔。 您可以跟踪任何给定时间段内的数字(但上面的示例仅显示2天),可以根据这些数字生成报告,显示一段时间内的趋势等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.