# No sequence is needed

**URL:** <https://www.ruby-forum.com/t/no-sequence-is-needed/159506>\
**Category:** Rails\
**Created:** [February 5, 2009, 7:04am UTC](https://www.ruby-forum.com/t/no-sequence-is-needed/159506 "2009-02-05T07:04:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [February 5, 2009, 7:04am UTC](https://www.ruby-forum.com/t/no-sequence-is-needed/159506/1 "2009-02-05T07:04:16Z")

</div>

Hi  
I would like to know how can i generate a model, without generating  
the sequence table in postgresql…Currently for example when I do

## def self.up create\_table :table1 do |t|

```
 A sequence is automatically generated like tables_id_seq

```

Thanks in advance  
Sijo

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [February 5, 2009, 4:36pm UTC](https://www.ruby-forum.com/t/no-sequence-is-needed/159506/2 "2009-02-05T16:36:13Z")

</div>

Sijo Kg wrote:

> Hi  
> I would like to know how can i generate a model, without generating  
> the sequence table in postgresql…Currently for example when I do
> 
> ## def self.up create\_table :table1 do |t|
> 
> ```
> A sequence is automatically generated like tables_id_seq
> 
> ```
> 
> Thanks in advance  
> Sijo

This can be done by using the :id =\> false option:  
create\_table :users, :id =\> false do |t|

However, I would highly recommend against doing this. With a few  
exceptions. The primary one being join tables that use a compound  
primary key composed of two foreign keys.

One important aspect of an ORM system like ActiveRecord is to have clear  
object identity. I do everything I can to avoid using natural primary  
keys, and I have VERY strong opinions about tables laking a primary key.

For a comprehensive overview that lines up nicely with my opinions here  
is a well written article:

> **[Surrogate vs Natural Primary Keys – Data Modeling Mistake 2 of 10](http://www.leerichardson.com/2007/08/in-case-youre-new-to-series-ive.html)**
>
> A blog about dev: web and mobile, especially .Net, OSS and CI.
