Telegram Web
Full Stack Open 2025
A deep dive into modern JavaScript-based web development: React, Redux, Node.js, GraphQL, TypeScript, CI/CD and containers. Self-paced, project-driven, with optional ECTS credits.

Rating ⭐️ 4.7 / 5 (33 Class Central reviews)

Students 👨‍🎓 11.1 K

Duration Self-paced (~200 hrs total)

Created by 👨‍🏫 Matti Luukkainen, Kalle Ilves & Jami Kousa (University of Helsinki)

🔗 COURSE LINK: https://fullstackopen.com/en/
👍53
🔹 SQL Series: Day 6️⃣ – Mastering the Primary Key

👋 Hey data adventurers! Today we’re shining the spotlight on the Primary Key - the VIP pass that makes every row unique and lightning-fast to find.

---

🛠 Origins: Why Primary Keys Were Born

* Prevent Duplicate Records: In early systems, it was all too easy to accidentally insert “two Alices” primary keys ensure each record stays one-of-a-kind.
* Enable Fast Access: As datasets grew, scanning millions of rows was impractical. Keys provided a built-in index for instant lookups.
* Support Relationships: To link data across tables reliably (think Orders → Customers), you need a stable, unique anchor.

---

+----+---------+-----------------------+  
| id | name | email |
+----+---------+-----------------------+
| 1 | Alice | [email protected] |
| 2 | Bob | [email protected] |
| 3 | Carol | [email protected] |
+----+---------+-----------------------+


🔑 What Makes a Primary Key Special?

* Unique – No two rows share the same value.
* Not NULL – Every record must have one.
* Indexed – The database auto-builds an index, so WHERE id = 2 is blazing fast.
* Integrity Enforcer – Prevents duplicates and anchors foreign-key relationships.

---


📋 1. Only One per Table
A table can have just one primary key.

> Even if it’s made of multiple columns (a composite key), you still pick *one* PK to enforce uniqueness.

---

🧩 2. Composite Primary Keys
When no single column does the job, team up two (or more) columns:

PRIMARY KEY (order_id, product_id)


This combo ensures each row is unique only when both values match.

---

🌱 3. Natural vs. Surrogate Keys
Primary key can be natural or surrogate key:
* Natural Key: Real-world data (e.g., email).
* Surrogate Key: System-generated (e.g., AUTO_INCREMENT or a UUID).

> Tip: Surrogates stay stable; naturals can change (and bite you!).

---

🛡 4. Best Practices
Stable – Pick values that won’t change.
Minimal – Keep it short; every byte counts.
Simple – One-column PKs are easiest; use composites only when needed.

---


🔐 While the Primary Key is our star today, remember there’s a whole key family waiting in the wings: Super Keys, Candidate Keys, Alternate Keys, Composite Keys, Unique Keys, Foreign Keys, Surrogate Keys… we’ll dive into those soon!
2🥰1
Bash brackets cheat sheet

For all those bash people out there, this might be useful

Man gotta love bash, right? 😁
7
Explaining CockroachDB

I created this post today on your request and shared on our ig page
🔥4
Should I share stuff like this in Telegram as well for those who doesn't use Instagram
Anonymous Poll
87%
yes
5%
no
8%
I don't care
2025/07/13 11:34:11
Back to Top
HTML Embed Code: