Using Primary Key / ID Field as an identifier in a URL

前端 未结 6 1344
广开言路
广开言路 2020-12-28 09:56

What are the pros and cons of using your databases primary key as a URL identifier? As an example, http://localhost/post/view/13 - 13 being my primary key for my posts tabl

6条回答
  •  清酒与你
    2020-12-28 10:14

    Reddit use numeric ID as well, but converted using Base 36, so it appears as a string. It's like hexadecmial number, which in fact is a string as well. The only difference is the base.

    Base 36 is "the most compact case-insensitive alphanumeric numeral system using ASCII characters" and it's easily encodable and decodable. Why 36? A-Z = 26 + 0-9 = 10.

提交回复
热议问题