# Alphanumeric id

**URL:** <https://www.ruby-forum.com/t/alphanumeric-id/132706>\
**Category:** Rails\
**Created:** [March 23, 2008, 9:18pm UTC](https://www.ruby-forum.com/t/alphanumeric-id/132706 "2008-03-23T21:18:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![William\_Fawcett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ea924/32.png) [@William\_Fawcett](https://www.ruby-forum.com/u/William_Fawcett)\
**Post date:** [March 23, 2008, 9:18pm UTC](https://www.ruby-forum.com/t/alphanumeric-id/132706/1 "2008-03-23T21:18:09Z")

</div>

I am working on a ticketing system, and the client has requested a  
special format for a ticket id the format would be alphanumeric with a  
3 character client tag, date, then a incremental number for the day,  
for example

ticket1 = ‘joe\_03232008\_00001’  
ticket2 = ‘joe\_03232008\_00002’  
ticket3 = joe\_03242008\_00001’  
etc

is there any way to get rails to allow custom formatted id’s? also, is  
this going to add alot of overhead? I can expect as many as 5000  
tickets per day. Is indexing going to become a problem?

BTW: I am working on a system that is coded in Rails 1.2.3, I can’t  
upgrade to 2.0 right now so the solution needs to be compatible.

Thanks  
-Will

---

<div class="post-metadata">

**Author:** ![William\_Fawcett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ea924/32.png) [@William\_Fawcett](https://www.ruby-forum.com/u/William_Fawcett)\
**Post date:** [March 24, 2008, 2:35am UTC](https://www.ruby-forum.com/t/alphanumeric-id/132706/2 "2008-03-24T02:35:06Z")

</div>

You want to be careful not to couple the id of the record to business  
logic. It is best for you to have another field to handle this; or  
just have a method that returns this ticket identifier you are after.

---

<div class="post-metadata">

**Author:** ![William\_Fawcett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ea924/32.png) [@William\_Fawcett](https://www.ruby-forum.com/u/William_Fawcett)\
**Post date:** [March 24, 2008, 2:50am UTC](https://www.ruby-forum.com/t/alphanumeric-id/132706/3 "2008-03-24T02:50:20Z")

</div>

On Sun, 2008-03-23 at 13:17 -0700, William Fawcett wrote:

> is there any way to get rails to allow custom formatted id’s? also, is  
> this going to add alot of overhead? I can expect as many as 5000  
> tickets per day. Is indexing going to become a problem?
> 
> BTW: I am working on a system that is coded in Rails 1.2.3, I can’t  
> upgrade to 2.0 right now so the solution needs to be compatible.

* * *

make you life easy…

have a primary key the standard numerical id field  
have a secondary key, assembled in whatever fashion you choose

That way, you give the customer what he wants yet you preserve sanity…

Craig
