Live data from Hacker News

SQL X-to-Y

damirsystems.com

21–30 of 30 posts

Re: SQL X-to-Y

#21

A Postgres feature I took way too long to discover: exclusion constraints, which is essentially "unique by some function of a column value" instead of "unique by a column value": https://www.postgresql.org/docs/13/ddl-constraints.html#DDL-...

You, probably like myself, took way too long to discover them because they have a fairly niche usage and are probably Postgres' least appropriately documented feature. It makes it hard to imagine the ways that it can be used. We should probably do something about that.

Re: SQL X-to-Y

#22
post #8
post #2

Why do I have to complete a captcha to access this website?

You don't. Just close the site! I was curious but not that curious... (edit: it's archived: http://archive.is/H9EYE )

They even dare to tell you to turn off ad blocking to get through the Cloudflare captcha. So much for "making the internet faster"...

Re: SQL X-to-Y

#23
post #6
post #2

Why do I have to complete a captcha to access this website?

Sorry, firewall thing -- dependent on recent (geo-ip) threats. Nothing to do with ads -- no ads.

What threat to you are bots viewing your website?

Re: SQL X-to-Y

#24
post #18
post #16

Is there further discussion of the "Alternate Key" somewhere? This is a new term to me. Is it like a candidate key?

In general there can be more than one candidate key for a given relation (table). Only one candidate key is "primary", all others are "alternate".

Thanks that makes sense.

Is this an industry term or are you just using it here to emphasize the difference?

Re: SQL X-to-Y

#25

A Postgres feature I took way too long to discover: exclusion constraints, which is essentially "unique by some function of a column value" instead of "unique by a column value": https://www.postgresql.org/docs/13/ddl-constraints.html#DDL-...

You, probably like myself, took way too long to discover them because they have a fairly niche usage and are probably Postgres' least appropriately documented feature. It makes it hard to imagine the ways that it can be used. We should probably do something about that.

I read the second description in the manual and amazed it exists. I can totally see use cases where you want "almost unique" constraints (same name, date of birth too close??)

Re: SQL X-to-Y

#27
post #24
post #18

Earlier quoted context omitted.

In general there can be more than one candidate key for a given relation (table). Only one candidate key is "primary", all others are "alternate".

Thanks that makes sense. Is this an industry term or are you just using it here to emphasize the difference?

I've seen alternate used in other places to refer to candidate keys that are not currently the primary key, though I'm fairly sure it isn't a defined standard term.

Re: SQL X-to-Y

#28
post #24
post #18

Earlier quoted context omitted.

In general there can be more than one candidate key for a given relation (table). Only one candidate key is "primary", all others are "alternate".

Thanks that makes sense. Is this an industry term or are you just using it here to emphasize the difference?

Industry term. But it is usually unknown to people who tend to use id as primary key for every table.

Re: SQL X-to-Y

#29
post #26

What is AK? I know PK and FK but AK has escaped me... at least the acronym...

Basically, every time you use UNIQUE in a column or set of columns that is not a PK, it is an AK (Alternate Key).

Re: SQL X-to-Y

#30
post #24

Earlier quoted context omitted.

Thanks that makes sense. Is this an industry term or are you just using it here to emphasize the difference?

Industry term. But it is usually unknown to people who tend to use id as primary key for every table.

Do you mean synthetic keys rather than natural keys?
Post reply on HN