我正在开发一个存储用户创建的调查的数据库。数据库需要为每个调查存储一个唯一的 ID。使用 SQL,我只需使用 SERIAL 列类型,以便每行都有一个自动递增的数字键。
SimpleDB 似乎将所有内容存储为字符串,这意味着我必须自己生成一个唯一的密钥。由于此密钥将成为 URL 的一部分,因此我认为 UUID 太长了。我希望能够加载类似以下内容的调查:
foo.com/1a
有没有办法让 SimpleDB 为您存储的每个项目生成唯一的行 ID?谢谢!
I'm working on a database that stores user-created surveys. The database needs to store a unique ID for each survey. Using SQL, I'd just use a SERIAL column type so each row has an auto-incrementing numeric key.
SimpleDB seems to store everything as a string, meaning I would have to generate a unique key myself. Since this key will be part of the URL, I think a UUID is just too long. I want to be able to load a survey with something like:
foo.com/1a
Is there any way to have SimpleDB generate a unique row ID for each item you store? Thanks!
发布评论
评论(2)
好的,所以你在这里征求意见......我会选择任何其他存储机制而不是 simpledb。例如,您可以轻松地使用 MongoDB 作为关系数据库的文档存储替代方案,并获得比 SimpleDB 更多的好处。
如果想要一个简短的唯一 URL,您可以搜索并找到一个 ruby 实现,将 ID 转换为短 ID。 http://blog.kischuk.com/ 2008/06/23/create-tinyurl-like-urls-in-ruby/
该实现会将 1174229 变成“7sH_”(根据帖子。YMMV)
所以,你会
在路由中
得到类似的东西并且这将创建
http://yourapp/7sh_
当然,这种技术也适用于非 mongo 安装。
OK, so you're asking for opinions here.... I would choice any other storage mechanism over simpledb. For example, you could easily go with MongoDB as a document storage alternative to a relational DB and get more benefits than with SimpleDB.
As far as wanting a short unique URL, you can search and find a ruby implementation to turn an ID into a shorted ID. http://blog.kischuk.com/2008/06/23/create-tinyurl-like-urls-in-ruby/
That implementation will turn 1174229 into "7sH_" (according to the post. YMMV)
So, you'd have something like
in routes
And that would create
http://yourapp/7sh_
Of course this technique can work for non-mongo installs.
SDB Explorer 支持从 MYSQL 批量上传到 Amazon SimpleDB。您可以使用 上传功能。上传时SDB Explorer会生成唯一ID。您甚至可以选择自己的 MYSQL 作为 itemName() 归档,即 Amazon SimpleDB 的唯一 ID。
SDB Explorer supports bulk upload from MYSQL to Amazon SimpleDB. You can upload your MYSQL data to Amazon SimpleDB using Upload feature. While upload SDB Explorer generates unique ID. Even you can choose you own MYSQL filed as a itemName() i.e. unique id for Amazon SimpleDB.