Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^5: Perl DBI and Foreign Keys

by soonix (Abbot)
on Apr 08, 2019 at 14:32 UTC ( #1232297=note: print w/replies, xml ) Need Help??


in reply to Re^4: Perl DBI and Foreign Keys
in thread Perl DBI and Foreign Keys

You will see that the ScoreCard table winds up containing an extra field, "rowid" that I didn't specify in CREATE TABLE ScoreCard.
That is SQLite specific, documented under https://sqlite.org/lang_createtable.html#rowid
Except for WITHOUT ROWID tables, all rows within SQLite tables have a 64-bit signed integer key that uniquely identifies the row within its table. …
BTW SQLite's last_insert_rowid() documentation explicitly refers to "the database connection which invoked the function", so should work with multiple parallel insertions.

Replies are listed 'Best First'.
Re^6: Perl DBI and Foreign Keys
by dsheroh (Prior) on Apr 09, 2019 at 07:27 UTC
    Yeah, rowid is SQLite-specific, but most[citation needed] major database engines will generate some kind of hidden unique identifier for each row if there isn't one explicitly specified. I believe this is because it's much harder to implement joins between tables which completely lack any way to uniquely identify rows. (I read something along those lines many years ago, but haven't really looked into it in any detail.) IIRC, MySQL and Postgres use UUIDs for this purpose and, of course, the field names involved will be engine-specific (if they're user-accessible at all).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1232297]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2019-05-22 23:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (140 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!