public inbox for [email protected]  
help / color / mirror / Atom feed
Using "object orientated" tables?
6+ messages / 4 participants
[nested] [flat]

* Using "object orientated" tables?
@ 2022-05-11 01:33 Simon Connah <[email protected]>
  2022-05-11 01:43 ` Re: Using "object orientated" tables? David G. Johnston <[email protected]>
  2022-05-11 01:50 ` Re: Using "object orientated" tables? Tom Lane <[email protected]>
  2022-05-11 16:03 ` RE: Using "object orientated" tables? Stephen Froehlich <[email protected]>
  0 siblings, 3 replies; 6+ messages in thread

From: Simon Connah @ 2022-05-11 01:33 UTC (permalink / raw)
  To: [email protected]

Hi,

I was wondering what the community thought of using table inheritance in PostgreSQL? Is it considered bad practice these days?

Basically, I have a users table and every user has a unique, not null UUID which is used as the primary key. There are only three columns on the table. User ID, Username, Email.

Having said that I'll have to store data about them which I don't want to do in one massive table as it would be ugly as hell. So what I want is my main user's table to stick to three columns and then sub-tables which inherit from it to add their own column? So for instance I might want to store an account balance for people making money on my site.

Hopefully, I've managed to explain what I mean properly. If you need any extra information then let me.

Simon.

Attachments:

  [application/pgp-signature] signature.asc (249B, ../../FD4Iyd89i-sbetQTcbUPO1SqWrYMGhzyso4ltpYmvWiI5LtHUxnPZNCyoJOhMOr3aQqvSKR9pISe55L3HStXrim-Q2wuufRQFkjGtAjIyS8=@protonmail.com/2-signature.asc)
  download

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Using "object orientated" tables?
  2022-05-11 01:33 Using "object orientated" tables? Simon Connah <[email protected]>
@ 2022-05-11 01:43 ` David G. Johnston <[email protected]>
  2022-05-11 01:51   ` Re: Using "object orientated" tables? Simon Connah <[email protected]>
  2 siblings, 1 reply; 6+ messages in thread

From: David G. Johnston @ 2022-05-11 01:43 UTC (permalink / raw)
  To: Simon Connah <[email protected]>; +Cc: pgsql-novice <[email protected]>

On Tue, May 10, 2022 at 6:33 PM Simon Connah <[email protected]>
wrote:

> Hi,
>
> I was wondering what the community thought of using table inheritance in
> PostgreSQL? Is it considered bad practice these days?
>
> Basically, I have a users table and every user has a unique, not null UUID
> which is used as the primary key. There are only three columns on the
> table. User ID, Username, Email.
>
> Having said that I'll have to store data about them which I don't want to
> do in one massive table as it would be ugly as hell. So what I want is my
> main user's table to stick to three columns and then sub-tables which
> inherit from it to add their own column? So for instance I might want to
> store an account balance for people making money on my site.
>
> Hopefully, I've managed to explain what I mean properly. If you need any
> extra information then let me.
>
>
I wouldn't use inheritance, especially since I do not want to carry around
copies of Username and Email.  Having a "core data" users table then adding
additional one-to-one related tables based upon application needs is quite
common.

David J.


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Using "object orientated" tables?
  2022-05-11 01:33 Using "object orientated" tables? Simon Connah <[email protected]>
  2022-05-11 01:43 ` Re: Using "object orientated" tables? David G. Johnston <[email protected]>
@ 2022-05-11 01:51   ` Simon Connah <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: Simon Connah @ 2022-05-11 01:51 UTC (permalink / raw)
  To: David G. Johnston <[email protected]>; +Cc: pgsql-novice <[email protected]>

------- Original Message -------On Wednesday, May 11th, 2022 at 02:43, David G. Johnston <[email protected]> wrote:


> On Tue, May 10, 2022 at 6:33 PM Simon Connah <[email protected]> wrote:
> 

> > Hi,
> > 

> > I was wondering what the community thought of using table inheritance in PostgreSQL? Is it considered bad practice these days?
> > 

> > Basically, I have a users table and every user has a unique, not null UUID which is used as the primary key. There are only three columns on the table. User ID, Username, Email.
> > 

> > Having said that I'll have to store data about them which I don't want to do in one massive table as it would be ugly as hell. So what I want is my main user's table to stick to three columns and then sub-tables which inherit from it to add their own column? So for instance I might want to store an account balance for people making money on my site.
> > 

> > Hopefully, I've managed to explain what I mean properly. If you need any extra information then let me.
> 

> 

> I wouldn't use inheritance, especially since I do not want to carry around copies of Username and Email. Having a "core data" users table then adding additional one-to-one related tables based upon application needs is quite common.
> David J.

Thank you for your reply. That makes more sense. I'll eventually get the hang of things!
Simon.

Attachments:

  [application/pgp-signature] signature.asc (249B, ../../yqMVDoZMX_lqEXTkqNcMxTbTKwiU0lPpdzC4_wv1aHpI1tnGzN9nTDZfrBi2-Zm4bFgT-dzuT-ISCtB1_VnZ39BCAQA0Rhj5OhD-y46-Il0=@protonmail.com/3-signature.asc)
  download

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Using "object orientated" tables?
  2022-05-11 01:33 Using "object orientated" tables? Simon Connah <[email protected]>
@ 2022-05-11 01:50 ` Tom Lane <[email protected]>
  2022-05-11 01:52   ` Re: Using "object orientated" tables? Simon Connah <[email protected]>
  2 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 2022-05-11 01:50 UTC (permalink / raw)
  To: Simon Connah <[email protected]>; +Cc: [email protected]

Simon Connah <[email protected]> writes:
> I was wondering what the community thought of using table inheritance in PostgreSQL? Is it considered bad practice these days?

Mmm ... not if the various caveats[1] don't bother you.  The biggest
stumbling block for most people, I think, is that you can't have
foreign keys that reference the whole inheritance hierarchy.

			regards, tom lane

[1] https://www.postgresql.org/docs/current/ddl-inherit.html#DDL-INHERIT-CAVEATS





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Using "object orientated" tables?
  2022-05-11 01:33 Using "object orientated" tables? Simon Connah <[email protected]>
  2022-05-11 01:50 ` Re: Using "object orientated" tables? Tom Lane <[email protected]>
@ 2022-05-11 01:52   ` Simon Connah <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: Simon Connah @ 2022-05-11 01:52 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: [email protected]

------- Original Message -------
On Wednesday, May 11th, 2022 at 02:50, Tom Lane <[email protected]> wrote:


> 

> 

> Simon Connah [email protected] writes:
> 

> > I was wondering what the community thought of using table inheritance in PostgreSQL? Is it considered bad practice these days?
> 

> 

> Mmm ... not if the various caveats[1] don't bother you. The biggest
> stumbling block for most people, I think, is that you can't have
> foreign keys that reference the whole inheritance hierarchy.
> 

> regards, tom lane
> 

> [1] https://www.postgresql.org/docs/current/ddl-inherit.html#DDL-INHERIT-CAVEATS

Thank you. I'll be sure to read that.

Simon.

Attachments:

  [application/pgp-signature] signature.asc (249B, ../../GplscGquyyDz8je2GgcpHDCPH3ukKsBVcesYOPKad8WHDghgfl9IfM4aMYKcWA-BK6-PXcK1EqfGZI6k2-io8Vr3oaLlmmpJ4XyVYFBXxzw=@protonmail.com/2-signature.asc)
  download

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* RE: Using "object orientated" tables?
  2022-05-11 01:33 Using "object orientated" tables? Simon Connah <[email protected]>
@ 2022-05-11 16:03 ` Stephen Froehlich <[email protected]>
  2 siblings, 0 replies; 6+ messages in thread

From: Stephen Froehlich @ 2022-05-11 16:03 UTC (permalink / raw)
  To: Simon Connah <[email protected]>; [email protected] <[email protected]>

Just to pile on, this sounds like a normalization problem ...

https://docs.microsoft.com/en-us/office/troubleshoot/access/database-normalization-description
https://en.wikipedia.org/wiki/Database_normalization

-----Original Message-----
From: Simon Connah <[email protected]> 
Sent: Tuesday, May 10, 2022 19:33
To: [email protected]
Subject: Using "object orientated" tables?

Hi,

I was wondering what the community thought of using table inheritance in PostgreSQL? Is it considered bad practice these days?

Basically, I have a users table and every user has a unique, not null UUID which is used as the primary key. There are only three columns on the table. User ID, Username, Email.

Having said that I'll have to store data about them which I don't want to do in one massive table as it would be ugly as hell. So what I want is my main user's table to stick to three columns and then sub-tables which inherit from it to add their own column? So for instance I might want to store an account balance for people making money on my site.

Hopefully, I've managed to explain what I mean properly. If you need any extra information then let me.

Simon.


^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2022-05-11 16:03 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11 01:33 Using "object orientated" tables? Simon Connah <[email protected]>
2022-05-11 01:43 ` David G. Johnston <[email protected]>
2022-05-11 01:51   ` Simon Connah <[email protected]>
2022-05-11 01:50 ` Tom Lane <[email protected]>
2022-05-11 01:52   ` Simon Connah <[email protected]>
2022-05-11 16:03 ` Stephen Froehlich <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox