Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can i use timestamp as primary key

 
vamshidhar nimbagiri
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
can i write mapping file using timestamp as primary key:

<class name="ddddddddd"
table="DBDBDBD">

<id name="timestamp" column="timestamp">
<generator class="assigned"/>
</id>

<property name="idType" type="string" column="id_type"/>
<property name="id" type="string" column="id"/>


</class>

please tell me

Thanks in Advance,
vamshidhar
 
Michael Duffy
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vamshidhar nimbagiri:
Hi
can i write mapping file using timestamp as primary key:

<class name="ddddddddd"
table="DBDBDBD">

<id name="timestamp" column="timestamp">
<generator class="assigned"/>
</id>

<property name="idType" type="string" column="id_type"/>
<property name="id" type="string" column="id"/>


</class>

please tell me

Thanks in Advance,
vamshidhar


I'm not a DBA, but I would not do this. I'd prefer a surrogate key, one that has no business significance.

If the smallest unit of time in a timestamp is milliseconds, you're limited to 1000 unique records per second. Don't know if that matters to you, but I wouldn't want to limit my app that way. (Hope I'm not making a foolish statement there. I'm sure some smart person will correct me if I am.)

I'd recommend an index on that column, because you might want fast searches based on timestamp, but I would not make it a primary key.
 
vamshidhar nimbagiri
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok Thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic