dongxi4235 2018-01-28 20:14
浏览 53
已采纳

动态表单输入服务

I have a project with php 7 (laravel) where I have to create a registration form for different services,My client wants to create services dynamically and every service has different registration form for example :

Service one have three inputs first name, last name and avatar

service tow have four inputs name email sexe and phone number

..

..

So what is the best solution to store this information? mysql database or json file or xml file

  • 写回答

1条回答 默认 最新

  • dongsu4345 2018-01-28 20:54
    关注

    As for the storage, in this case a database is a natural choice as it handles concurrent access out of the box, while storing in a file would require some complications on your side.

    But your real concern seems to be with the data structure, not the storage. The challenge here is that different data providers provide different structures and you want them all in one structure.

    If service 1 provides first name and last name as separate fields, and service 2 sees them as a single field, the question is whether you make a single field (like in service 2) and concatenate values coming from service 1, or you make multiple name fields (like in service 1) and invent a method to separate values coming from service 2 into corresponding parts.

    To make this decision wisely, you have to look how your data is to be used. If you want a robot to send out emails starting with 'Dear Ms. Last Name' line, you will need to keep last name separately. If you have no such task in your planning horizon, you may wish to skip the dividing challenge and simply store all name fields in a single field.

    The problem of a correct data structure for folks' names is deeper than it seems. Have a look at this nice post: http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/

    At any rate, no-one at stackoverflow knows what your data is to be used for. It is up to you to communicate to your client that they share this knowledge with you. Then get some time to sit down and to sketch the structure that will suffice your immediate needs. Outline use cases, draw an ER diagram, put down on the paper some pseudocode to illustrate what data fields are needed by your system.

    And most importantly, don't be afraid that it doesn't come out as good as you want. The needs change over time, your understanding deepens, and it is only natural to constantly adapt your database structure and your code to the new reality. It's okay. Come on, work it out.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line