# #dt260208
# #sql
# #primarykey
# #foreignkey
# #SQLite

I had chatgpt refactor the bookbiz database schema (from PracticalSQL book 2nd ed). It added primary and foreign keys. I then had it refactor for SQLite specifically.

https://chatgpt.com/share/69894b9c-b944-8008-b758-b283987b4086

...

Highlights:

1. SQLite-Idiomatic Schema (Clean Rewrite)
Global settings (critical in SQLite)
PRAGMA foreign_keys = ON;
PRAGMA journal_mode = WAL;
PRAGMA synchronous = NORMAL;

ChatGPT - SQLite schema recommendations

Shared via ChatGPT

ChatGPT

Auto-Increment IDs Have GAPS Forever?!

IDs are BROKEN! Failed INSERT consumes the auto-increment ID! User #1, skip #2, User #3! Your IDs have permanent GAPS! This breaks ID-based logic! Watch this chaos!

#sql #sqlbug #autoincrement #primarykey #idgaps #failedinsert #sqlfails #productionbug #sqlshorts #sqlwtf #identitycolumn #dataintegrity

https://www.youtube.com/watch?v=qF3obGJL_MY

Auto-Increment IDs Have GAPS Forever?! #failedinsert

YouTube

Django 5.2 支援 composite primary key

看到 Django 5.2 的公告,裡面列出了比較重大的改變,其中一個注意到的是支援 Composite (Compound) Primary Key 了:「Django 5.2 released」,完整的 release notes 則是在「Django 5.2 release notes」這邊可以看到。 就是因為這些 ORM library 不支援 compsite primary key,所以才會有 best (?) practice 要求每個表格都要有 primary key,而且是單一欄位... 大家應該都習以為常了,怎麼會突然在 2025 年才想要支援? …

https://blog.gslin.org/archives/2025/04/04/12331/django-5-2-%e6%94%af%e6%8f%b4-composite-primary-key/

#composite #compound #database #db #django #library #orm #pk #PrimaryKey #rdbms

Django 5.2 支援 composite primary key

看到 Django 5.2 的公告,裡面列出了比較重大的改變,其中一個注意到的是支援 Composite (Compound) Primary Key 了:「Django 5.2 released」,完整的 release notes 則是在「Django 5.

Gea-Suan Lin's BLOG
IBM i Database RowID: Unique Record Identification in AS400
Master IBM i Database RowID for robust data management! Learn reliable methods for unique record identification using primary keys & other strategies. Avoid pitfalls of using RRN. #IBMiDatabase #DB2fori #AS400data #UniqueRecordID #Primarykey #DataManagement
https://tech-champion.com/database/db2luw/ibm-i-database-rowid-unique-record-identification-in-as400/
Composite Primary Keys: When Simplicity Trumps Complexity in Database Design
Optimizing database design: Single vs. composite primary keys. For smaller databases, a single, auto-incrementing primary key often offers superior performance & maintainability. Simplicity trumps complexity! Composite primary keys add complexity to updates & queries. #DatabaseDesign #PrimaryKey #CompositeKey #SQL #DatabaseOptimization #Performance
https://tech-champion.com/database/db2luw/composite-primary-keys-when-simplicity-trumps-complexity-in-database-design/
Q: What sits between you and your Data? A: Identifiers! Read: #URI #LinkedData #PrimaryKey #ForeignKey #ODBC #NewSQL

Keys in DBMS | Super Key| Candidate Key| Primary Key| Foreign Key |DBMS Lect 14| Shanu Kuttan |Hindi

DBMSKeys #SuperKey #CandidateKey #PrimaryKey #ForeignKey #AlternateKey #CompositeKey #Keys in DBMS This video ... source

https://quadexcel.com/wp/keys-in-dbms-super-key-candidate-key-primary-key-foreign-key-dbms-lect-14-shanu-kuttan-hindi/

Keys in DBMS | Super Key| Candidate Key| Primary Key| Foreign Key |DBMS Lect 14| Shanu Kuttan |Hindi - QuadExcel.com

DBMSKeys #SuperKey #CandidateKey #PrimaryKey #ForeignKey #AlternateKey #CompositeKey #Keys in DBMS This video ... source

QuadExcel.com
https://andrewlock.net/generating-sortable-guids-using-newid/ - #PrimaryKey: auto-incrementing int or Guid? What about #NewId? It's sortable-ish. Great post @andrewlock.
Generating sortable Guids using NewId

In this post I discuss the pros-and-cons of using integer vs Guids for IDs, and introduce NewId as an alternative to Guid with some nice properties

Andrew Lock | .NET Escapades

I love it when an #RDB #database sports a #primaryKey in one table that doesn't have a corresponding column anywhere else. That's just great #dataModeling right there.

#dataAnalysis #SQL