duandi8613 2015-04-30 20:07 采纳率: 100%
浏览 24

具有自定义列标题的水平与垂直SQL

I'm struggling finding the most efficient way to approach this DB design. This is for a Client who want to manage their Contacts. The Software currently is Horizontal which allows each Client to modify up to 5 columns for Field label questions. These 5 static columns are also in the Contact's table to store the results per Contact. For this example we are only using two tables, Client and Contact.

The Issue. I have been asked to extend this so a Clients can have an N amount of custom Field Label questions. One Client my want 1, another may want 20, 34, or N. I can't see this being done correctly Horizontally but easily vertically. The issue then becomes, I have to make a pivot to display the Vertical results in a row/column display.

The Question. Am I looking at this wrong, and should I change my perspective, and stick with a Horizontal table? If so, could someone explain to me the approach I should take?

  • 写回答

2条回答 默认 最新

  • duanmianzhou5353 2015-04-30 20:23
    关注

    I would consider storing the data in XML in a 3rd table with a FK relationship to the Client table. Your xml would have additional elements for each N number of custom fields. Then change the application so instead of displaying static fields, it derives those fields from the XML.

    The plausibility of my answer depends somewhat on the architecture of the application displaying this data and assumes you have control over changing it. Since the question is a bit vague, and I don't even know what language your app is written in or whether it is web based or not, I can't really provide you with any code examples.

    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?