News for hackers. Stuff that matters.
Re:SQL X-to-Y by Footkerchief on Sunday November 01, 2020 @02:18PM (#24961752)
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-...
Re:SQL X-to-Y by darksaints on Sunday November 01, 2020 @03:57PM (#24962448)
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 by ramraj07 on Sunday November 01, 2020 @09:13PM (#24964295)
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 by gberger on Sunday November 01, 2020 @01:22PM (#24961353)
Why do I have to complete a captcha to access this website?
Re:SQL X-to-Y by afandian on Sunday November 01, 2020 @02:16PM (#24961731)
You don't. Just close the site! I was curious but not that curious...

(edit: it's archived: http://archive.is/H9EYE )

Re:SQL X-to-Y by t0mas88 on Sunday November 01, 2020 @04:41PM (#24962760)
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 by yamrzou on Sunday November 01, 2020 @02:25PM (#24961798)
In addition, I find the new hCaptcha used by Cloudflare much worse than reCAPTCHA. It's slower, with ambiguous inputs demanding more mental effort, and sometimes it just refuses my correct answers.
Re:SQL X-to-Y by flotzam on Sunday November 01, 2020 @02:40PM (#24961906)
Google probably has a good enough handle on you to serve the easy captchas. But keep in mind that for users they can't fingerprint (e.g. with Tor Browser), reCAPTCHA is usually insanely hard or even blocked ("Your computer or network may be sending automated queries"). hCaptcha has been heavenly compared to that.
Re:SQL X-to-Y by bigbubba on Sunday November 01, 2020 @03:57PM (#24962447)
'Hard' is not quite the right word for it. reCAPTCHA frequently rejects objectively correct responses when they fail to fingerprint you.
Re:SQL X-to-Y by dspillett on Sunday November 01, 2020 @01:48PM (#24961514)
I've seen some sites suggest they CAPTCHAs will go away if I disable my ad blocker[†], so if not everyone is getting it this could be a factor. Before I bother even clicking to see if I get the CAPTCHA, is the content worth the effort?

[†] I can see how this replaces ad revenue at all, so I assume it is an attempt to make running an ad blocker seem like an inconvenience rather than a benefit.

Re:SQL X-to-Y by jontro on Sunday November 01, 2020 @01:55PM (#24961569)
I still got the captcha even though I'm running no adblocker
Re:SQL X-to-Y by panda17 on Sunday November 01, 2020 @01:55PM (#24961567)
Sorry, firewall thing -- dependent on recent (geo-ip) threats. Nothing to do with ads -- no ads.
Re:SQL X-to-Y by orf on Sunday November 01, 2020 @02:17PM (#24961748)
Turn it off.
Re:SQL X-to-Y by crtasm on Sunday November 01, 2020 @05:05PM (#24962940)
What threat to you are bots viewing your website?
Re:SQL X-to-Y by netsharc on Sunday November 01, 2020 @01:24PM (#24961364)
Same here, today I figured out I'm not human...
Re:SQL X-to-Y by SPBS on Sunday November 01, 2020 @02:31PM (#24961843)
I find the notation compact but confusing. Are Thing and Category essentially tables? What does `thing {T, C}` mean, if T already means Thing?
Re:SQL X-to-Y by panda17 on Sunday November 01, 2020 @02:48PM (#24961952)
A thing is uniquely identified by T, category by C.

May read it as: CREATE TABLE thing (T_ID integer, C_ID integer)

Re:SQL X-to-Y by mulmen on Sunday November 01, 2020 @03:37PM (#24962287)
Is there further discussion of the "Alternate Key" somewhere? This is a new term to me. Is it like a candidate key?
Re:SQL X-to-Y by panda17 on Sunday November 01, 2020 @03:45PM (#24962359)
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".
Re:SQL X-to-Y by mulmen on Sunday November 01, 2020 @05:45PM (#24963218)
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 by dspillett on Monday November 02, 2020 @05:05AM (#24966361)
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 by panda17 on Tuesday November 03, 2020 @03:33PM (#24983663)
Regarding the "industry term", search:

   site:oracle.com "alternate key"

   site:microsoft.com "alternate key"

   site:ibm.com "alternate key"
Re:SQL X-to-Y by dspillett on Tuesday November 03, 2020 @07:47PM (#24985701)
"defined standard" !== "industry term", though I accept your point that it appears to be more common than I was thinking.

IIRC it wasn't introduced to me when learning databases academically which I was assuming to be a standards compliant environment, but that was quite some years ago so I may or may not R C...

Re:SQL X-to-Y by marcos100 on Monday November 02, 2020 @05:12AM (#24966408)
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 by mulmen on Monday November 02, 2020 @02:50PM (#24972348)
Do you mean synthetic keys rather than natural keys?
Re:SQL X-to-Y by kthejoker2 on Sunday November 01, 2020 @03:51PM (#24962414)
Yes, it is exactly a candidate key as they describe it - simply another field which uniquely identifies rows in the entity.

EDIT: Agree with panda17, they're using it as "candidate keys which were not chosen as primary key."

Re:SQL X-to-Y by taffer on Sunday November 01, 2020 @01:40PM (#24961465)
SQL Assertions are incidentally the most requested feature for the Oracle database: https://community.oracle.com/tech/apps-infra/discussion/4390...
Re:SQL X-to-Y by mulmen on Sunday November 01, 2020 @03:42PM (#24962330)
/me mumbles something about the BOOLEAN data type.
Re:SQL X-to-Y by mongol on Monday November 02, 2020 @02:00AM (#24965378)
What is AK? I know PK and FK but AK has escaped me... at least the acronym...
Re:SQL X-to-Y by marcos100 on Monday November 02, 2020 @05:22AM (#24966455)
Basically, every time you use UNIQUE in a column or set of columns that is not a PK, it is an AK (Alternate Key).