首页 \ 问答 \ 服务台数据库设计(Help Desk Database Design)

服务台数据库设计(Help Desk Database Design)

我所在的公司对于服务台系统有着非常特殊和独特的需求,所以没有任何开源系统能够为我们工作。 既然如此,我使用PHP和MySQL创建了一个自定义系统。 它远非完美,但比上一次使用的系统要好得多。 相信我! 它很好地满足了我们大部分的需求,但是我对数据库设置的方式有疑问。 这里是主要表格:

ClosedTickets
ClosedTicketSolutions
Locations
OpenTickets
OpenTicketSolutions
Statuses
Technicians

当用户提交帮助请求时,它将进入“OpenTickets”表。 当技术人员处理这个问题时,他们会提交条目并描述他们所做的事情。 这些条目放在“OpenTicketSolutions”表中。 问题解决后,处理该问题的最后一位技术人员将关闭该故障单并将其移至“ClosedTickets”表。 所有解决方案条目也都移到“ClosedTicketSolutions”表中。 其他表(位置,状态和技术人员)作为标准化手段存在(每个位置,状态和技术人员都有一个被引用的ID)。

我现在遇到的问题是这样的:

当我想查看所有打开的故障单的列表时,SQL语句有点复杂,因为我必须离开“位置”,“状态”和“技术人员”表。 来自各种表格的字段也需要可搜索。 查看SQL语句搜索由任何名字中包含“John”的人提交的门票的封闭门票有多复杂:


SELECT ClosedTickets.*, date_format(ClosedTickets.EntryDate, '%c/%e/%y %l:%i %p') AS Formatted_Date, date_format(ClosedDate, '%c/%e/%y %l:%i %p') AS Formatted_ClosedDate, Concat(Technicians.LastName, ', ', Technicians.FirstName) AS TechFullName, Locations.LocationName, date_format(ClosedTicketSolutions.EntryDate, '%c/%e/%y') AS Formatted_Solution_EntryDate, ClosedTicketSolutions.HoursSpent AS SolutionHoursSpent, ClosedTicketSolutions.Tech_ID AS SolutionTech_ID, ClosedTicketSolutions.EntryText
FROM ClosedTickets
LEFT JOIN Technicians ON ClosedTickets.Tech_ID = Technicians.Tech_ID
LEFT JOIN Locations ON ClosedTickets.Location_ID = Locations.Location_ID
LEFT JOIN ClosedTicketSolutions ON ClosedTickets.TicketNum = ClosedTicketSolutions.TicketNum
WHERE (ClosedTickets.FirstName LIKE '%John%')
ORDER BY ClosedDate Desc, ClosedTicketSolutions.EntryDate, ClosedTicketSolutions.Entry_ID

我现在无法做的一件事是同时搜索开放票和封闭票。 我不认为工会会适用于我的案子。 所以我想知道是否应该将打开和关闭的票据存储在同一个表中,并且只需要一个指示是否关闭票证的字段。 我可以预见的唯一问题是我们已经有很多已关闭的门票(将近30,000个),因此整个系统可能会执行得很慢。 将开放票和封闭票结合起来会不是个好主意?


The company I work at has very specific and unique needs for a help desk system, so none of the open source systems will work for us. That being the case, I created a custom system using PHP and MySQL. It's far from perfect, but it's infinitely better than the last system they were using; trust me! It meets most of our needs quite nicely, but I have a question about the way I have the database set up. Here are the main tables:

ClosedTickets
ClosedTicketSolutions
Locations
OpenTickets
OpenTicketSolutions
Statuses
Technicians

When a user submits a help request, it goes in the "OpenTickets" table. As the technicians work on the problem, they submit entries with a description of what they've done. These entries go in the "OpenTicketSolutions" table. When the problem has been resolved, the last technician to work on the problem closes the ticket and it gets moved to the "ClosedTickets" table. All of the solution entries get moved to the "ClosedTicketSolutions" table as well. The other tables (Locations, Statuses, and Technicians) exist as a means of normalization (each location, status, and technician has an ID which is referenced).

The problem I'm having now is this:

When I want to view a list of all the open tickets, the SQL statement is somewhat complicated because I have to left join the "Locations", "Statuses", and "Technicians" tables. Fields from various tables need to be searchable as well. Check out how complicated the SQL statement is to search closed tickets for tickets submitted by anybody with a first name containing "John":


SELECT ClosedTickets.*, date_format(ClosedTickets.EntryDate, '%c/%e/%y %l:%i %p') AS Formatted_Date, date_format(ClosedDate, '%c/%e/%y %l:%i %p') AS Formatted_ClosedDate, Concat(Technicians.LastName, ', ', Technicians.FirstName) AS TechFullName, Locations.LocationName, date_format(ClosedTicketSolutions.EntryDate, '%c/%e/%y') AS Formatted_Solution_EntryDate, ClosedTicketSolutions.HoursSpent AS SolutionHoursSpent, ClosedTicketSolutions.Tech_ID AS SolutionTech_ID, ClosedTicketSolutions.EntryText
FROM ClosedTickets
LEFT JOIN Technicians ON ClosedTickets.Tech_ID = Technicians.Tech_ID
LEFT JOIN Locations ON ClosedTickets.Location_ID = Locations.Location_ID
LEFT JOIN ClosedTicketSolutions ON ClosedTickets.TicketNum = ClosedTicketSolutions.TicketNum
WHERE (ClosedTickets.FirstName LIKE '%John%')
ORDER BY ClosedDate Desc, ClosedTicketSolutions.EntryDate, ClosedTicketSolutions.Entry_ID

One thing that I'm not able to do right now is search both open and closed tickets at the same time. I don't think a union would work in my case. So I'm wondering if I should store the open and closed tickets in the same table and just have a field indicating whether or not the ticket is closed. The only problem I can forsee is that we have so many closed tickets already (nearly 30,000) so the whole system might perform slowly. Would it be a bad idea to combine the open and closed tickets?


原文:https://stackoverflow.com/questions/2539986
更新时间:2023-11-01 17:11

最满意答案

aggregate是你的答案

db.foo.aggregate({"$project" : {"two" : "$friends.two"}}).result

还有另一种方法可以做到这一点(获得不同的价值)

db.foo.aggregate([      
    {'$project': {  
                    union:{$setUnion:["$friends.two"]}
                 }
    }
]).result;

aggregate is your answer

db.foo.aggregate({"$project" : {"two" : "$friends.two"}}).result

there is another way to do that (getting distinct values)

db.foo.aggregate([      
    {'$project': {  
                    union:{$setUnion:["$friends.two"]}
                 }
    }
]).result;

相关问答

更多

相关文章

更多

最新问答

更多
  • 在开发React应用程序时编译/转换代码(Compile/transpile code while developing React app)
  • 将MultiPoint序列化为GeoJSON文件(Serialize MultiPoint to GeoJSON file)
  • 将字符串截断为特定数量的字符,忽略HTML(Truncate string to certain amount of characters, ignoring HTML)
  • Sqlserver监视时间的变化(Sqlserver watch for time change)
  • Srcset属性 - 最大宽度问题(Srcset attribute - max-width issue)
  • 如何验证数据库中是否存在记录?(How to verify existence of a record in database?)
  • SQL JOIN来自不同表的行具有相同的值(SQL JOIN row from different table with the same values)
  • NSTextField - 使用KVO进行输入验证?(NSTextField - Input validation with KVO?)
  • 在Javascript中,如何检查数组是否有重复值?(In Javascript, how do I check if an array has duplicate values? [duplicate])
  • 获取过滤器从spark数据帧中删除的行的示例(Get examples for rows that are removed by a filter from a spark dataframe)
  • 如果Shape在屏幕外,是否执行Graphics2D.draw?(Is Graphics2D.draw performed if the Shape is offscreen?)
  • 如果没有头文件,如何定义静态成员?(How to define a static member in case there is not header file?)
  • NSLocalizedStringFromTableInBundle:没有获取key的值(NSLocalizedStringFromTableInBundle : not getting values for key)
  • Google Cloud Messanger,“比预期的更多”(Google Cloud Messanger, “More acks than expected”)
  • HorizontalScrollView不起作用(HorizontalScrollView not working)
  • 关闭所有表单后退出应用程序(Quit Application when all forms is closed)
  • 玉林哪个会计培训学校有周末上课的!
  • java的。(java. Unique identifier for each visitor. How better generated?)
  • 希望大家告诉我学java编程的方法?
  • 在GAS嵌入式环境中通过Javascript刷新HTML文档(Refresh HTML Document via Javascript in a GAS Embedded Environment)
  • 当我在另一个类中调用它时,setText不起作用(setText does not work when I call it in another class)
  • 无法在静态字段中设置变量值(Can't Set variable value in Static Field)
  • IE9布局错误 - 在早期的IE版本中很好(IE9 Layout Bug - fine in earlier IE versions)
  • 按钮命令上的WPF新DataGrid行参数为NULL(WPF New DataGrid Row Parameter NULL on Button Command)
  • Wordpress上的CSS配置(CSS configuration on Wordpress )
  • 关于OpenGL设置的问题以及在窗口中绘制掩码的问题(Questions about OpenGL Settings and drawing over a mask in a window)
  • Matlab编码器fzero功能(Matlab coder fzero function)
  • Autodesk Maya,C ++和OpenGL渲染引擎(Autodesk Maya, C++ and OpenGL rendering engine)
  • 选择记录字段包含另一个字段的最大值(Select field of record contains max of another field)
  • 可选参数在Swashbuckle.AspNetCore中导致null异常(Optional parameter causes null exception in Swashbuckle.AspNetCore)