简体   繁体   English

主键的类型/值应为无限制

[英]What should be the type/value of a primary key that should be unlimited

I am making a messaging system wherein both authenticated and unauthenticated users should be able to use. 我正在创建一个消息传递系统,其中经过身份验证的用户和未经身份验证的用户都应该能够使用。 Each index of the message should be unique. 消息的每个索引应该是唯一的。 I am thinking of using bigint but it has a limit of about 18446744073709551615 (unsigned) which would not be ideal for me if I want to keep a record of all the messages. 我正在考虑使用bigint,但是它的限制大约为18446744073709551615(无符号),如果我想保留所有消息的记录,这对我来说并不理想。 Also, I am thinking of a timestamp but there is a possibility that more than one user will post a message at the same time. 另外,我在考虑时间戳,但是有可能多个用户同时发布一条消息。 Hence, the created timestamp will collide with other timestamp. 因此,创建的时间戳将与其他时间戳冲突。

Do you guys have an idea what should be done here? 你们知道在这里应该做什么吗?

Thank you in advance. 先感谢您。 :D :D

Seriously? 认真吗 If 100 messages are posted every second, BigInt will give you sufficient ids for, by my rough calculation, 6 billion years. 如果每秒发布100条消息,按照我的粗略估算,BigInt将为您提供60亿年的足够ID。 By then you can probably archive a few messages and start the sequence over. 到那时,您可能可以存档一些消息并重新开始序列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM