# Create/new on tables without sequences?

**URL:** <https://www.ruby-forum.com/t/create-new-on-tables-without-sequences/98019>\
**Category:** Rails\
**Created:** [December 12, 2005, 4:27am UTC](https://www.ruby-forum.com/t/create-new-on-tables-without-sequences/98019 "2005-12-12T04:27:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![csn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/db5fbb/32.png) [@csn](https://www.ruby-forum.com/u/csn)\
**Post date:** [December 12, 2005, 4:27am UTC](https://www.ruby-forum.com/t/create-new-on-tables-without-sequences/98019/1 "2005-12-12T04:27:23Z")

</div>

I have a table as such:

table1\_id|table2\_id

No id, primary key, sequence, etc. When I try to  
create/new a record, I get this:

table21.create(:table1\_id=\>1, :table2\_id=\>2)

PGError: ERROR: relation “table12\_id\_seq” does not  
exist  
: SELECT currval(‘table12\_id\_seq’)

Does Rails really expect all tables to have id  
sequences, or is there a way around this?

thanks  
csn

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[Yahoo Mail - Organized Email](https://mail.yahoo.com)**
>
> It's time to get stuff done with Yahoo Mail. Just add your Gmail, Outlook, AOL or Yahoo Mail to get going. We automatically organize all the things life throws at you, like receipts and attachments, so you can find what you need fast. Plus, we've got...

---

<div class="post-metadata">

**Author:** ![csn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/db5fbb/32.png) [@csn](https://www.ruby-forum.com/u/csn)\
**Post date:** [December 12, 2005, 6:12am UTC](https://www.ruby-forum.com/t/create-new-on-tables-without-sequences/98019/2 "2005-12-12T06:12:42Z")

</div>

CSN,

Is there a reason you actively don’t want to have a primary key in  
your join tables? Even in cases where you only expect a one to one  
relationship (example: husband to wife) it doesn’t hurt to have a  
primary key, and if your assumptions don’t hold true (say you take on  
some polygamous users) you’ll have a mess to clean up.

pt.

On 12/11/05, CSN [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> exist  
> Tired of spam? Yahoo! Mail has the best spam protection around  
> [http://mail.yahoo.com](http://mail.yahoo.com)
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
Parker T.

> **[ParkErt.com is for sale | HugeDomains](https://www.hugedomains.com/domain_profile.cfm?d=parkert.com)**
>
> Join thousands of people who own a premium domain. Affordable financing available.

510.541.0125

---

<div class="post-metadata">

**Author:** ![csn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/db5fbb/32.png) [@csn](https://www.ruby-forum.com/u/csn)\
**Post date:** [December 12, 2005, 7:06am UTC](https://www.ruby-forum.com/t/create-new-on-tables-without-sequences/98019/3 "2005-12-12T07:06:47Z")

</div>

A mess? Dealing with join table data is pretty simple.  
Primary keys for them are useless IMO.

My last two questions are moot - HABTM is pretty  
slick. Got everything working :).

csn

— Parker T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> some polygamous users) you’ll have a mess to clean
> 
> > No id, primary key, sequence, etc. When I try to  
> > sequences, or is there a way around this?  
> > Rails mailing list
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[\[object](https://mail.yahoo.com/)**
>
> \[object

---

<div class="post-metadata">

**Author:** ![csn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/db5fbb/32.png) [@csn](https://www.ruby-forum.com/u/csn)\
**Post date:** [October 4, 2007, 1:01pm UTC](https://www.ruby-forum.com/t/create-new-on-tables-without-sequences/98019/4 "2007-10-04T13:01:16Z")

</div>

Dear Sir,

I’ve got the same troubles as you on creating new records on tables  
without sequences.  
Could you, please, tell me that is the solution that you’ve found?  
Thank you in advance.

ag

CSN wrote:

> Got everything working :).
> 
> csn
