r/learnSQL • u/dagscriss3 • Dec 09 '25
Primary and foreign key
Hey guys. Im on my journey on learning sql and im on joins now. Ive created 2 tables and both has primary key. When i ask claude if my code is good, it says that my 2nd table needs a foreign key to connect it to the 1st table, but isnt that what primary key is for? I just need someone to eli5 it to me.
18
Upvotes
View all comments
Show parent comment
2
u/squadette23 Dec 10 '25
Interesting, thanks. ChatGPT thinks that it's mostly classic commerical vendors support this: SQL Server, Oracle, DB2, Teradata. Postgresql/Mysql ignore FKs for optimization.
https://link.springer.com/article/10.1007/s00778-021-00676-3
https://arxiv.org/html/2406.06886v2