dongxin1980 2014-09-15 08:33
浏览 27

为什么使用ID来查找数据而不是使用标题 - 请帮助我说明我的观点

Please help me argue my point.

I am working on a website project with a team of developers, we are developing the system in 3 parts. The one part is the API, 2 back-end and front-end. Both the front end and back-end gets and stores data by sending it to the API.

I am specifically responsible for the front end. I am using Codeigniter as my framework.

A little background: The app is a sports betting site.

This is the problem: The developers of the API use the name of for example a tournament or fixture or sport to do the lookup, I pass the name of a tournament for example: www.example.com/sport/add_bet/{tournament_name}

The problem I have with this is that the tournament name as entered into the system by humans might have characters such as spaces, forward slashes, etc in the name.

As you can imagine using a forward slash in the url will completely break the system, since we use them to call different controllers, actions and to pass variables.

I am trying to get them to change to using a simple primary key id field, to perform the lookup of the data. For some reason these developers don't want to do this.

The project manager that manages this project (not a programmer and no experience of programming) had a chat to them about this issue, but still they don't want to change, and they told her that it is a matter of personal preference on which way to go.

As far as I know ID's have always been the way to do it.

Could you guys/girls please help me argue my point by giving some reasons as to why I am correct or incorrect in your view. I would like to provide your answers as motivation to get them to change over to doing it the right way.

Your help/answers/suggestions would be much appreciated.

  • 写回答

3条回答 默认 最新

  • duanqing3026 2014-09-15 08:42
    关注

    The most important thing is the id will be unique as it is should be the primary key. so searching by ids will return unique results.

    But the multiple record may have save title if you didn't validate them at the time of saving.

    And also if you want some joins or something like that the id would help it.

    And the should never trust the user and expect them to work as you wanted.

    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测