@arrionknight
Instagram · Screen Recording
@arrionknight SQL Composite Key Primary Key and Foreign Key example‼️ #sql #python #hoodcoding #computerscience #compsci
@arrionknight
Instagram · Screen Recording
@arrionknight SQL Composite Key Primary Key and Foreign Key example‼️ #sql #python #hoodcoding #computerscience #compsci
Performance
Video #11956 · Screen Recording
[01]
The speaker explains how to use SQL to check if data is being shared. He creates two tables, 'Huzz' and 'Sharks', and sets up primary and foreign keys to ensure data integrity. He demonstrates how to create a query to check if the 'Huzz' are going, using sample data and showing how the foreign key constraint prevents incorrect data entry.
[02]
[03]
[04]
[05]
What stops the scroll in the first 3 seconds
Title hook · 55%
Check if Huzz are going...
Verbal hook · 40%
This is how you find out if the huhs are going.
Visual hook · 5%
Close-up shot of the speaker with braided hair and a black Adidas shirt, speaking directly to the camera.
[06]
Steal this for your own video
This is how you check if your are going to .
[07]
The promise the opener makes, and how the video pays it back
Hook
State the problem of data sharing and introduce SQL as a solution.
Payoff
Explain how the query identifies invalid data based on the table relationships.
[08]
The structural pattern this video runs on
Framework
SQL Data Integrity Check
Demonstrates how to use SQL constraints to ensure data integrity and prevent invalid relationships between tables.
Table Definition
Create the first table with a primary key to store basic information.
Relationship Setup
Create a second table with a foreign key referencing the first table's primary key to establish a relationship.
Composite Key Explanation
Explain the concept of a composite primary key.
Data Insertion Attempt
Attempt to insert invalid data that violates the foreign key constraint.
Constraint Demonstration
Show the error message resulting from the constraint violation.
Query Explanation
Explain the query used to check data integrity.
SQL Composite Key Primary Key and Foreign Key example‼️ #sql #python #hoodcoding #computerscience #compsci
title · beginning
Check if Huzz are going...
informational · beginning
THIS IS HOW
informational · beginning
HUZZ ARE GOING
informational · beginning
IF YOU WANNA MAKE SURE
informational · beginning
YOU'RE NOT SHARING
informational · beginning
YOU GOTTA
informational · middle
SO THE FIRST THING
informational · middle
WE'RE GONNA
informational · middle
CALLED
informational · middle
WE'RE GONNA
informational · middle
FIRST NAME AND
informational · middle
THE LAST
informational · middle
ALL
informational · middle
AND
informational · middle
AND WE MAKE THE
informational · middle
KEY
informational · middle
THIS NEXT PART IS
informational · middle
IMPORTANT TO SEE
informational · middle
IF THE HUZZ ARE
informational · middle
SO NOW
informational · middle
ANOTHER
informational · middle
AND IN THE SHARKS
informational · middle
GONNA HAVE THE
informational · middle
AND THE PRIMARY
informational · middle
GONNA BE
informational · middle
GONNA BE A
informational · middle
COMBINATION
informational · middle
THE SHARK
informational · middle
AND THE HUZZ
informational · middle
WE CALL THIS
informational · middle
PRIMARY
informational · middle
IN THE SHARK'S
informational · middle
GONNA MAKE OUR
informational · middle
FOREIGN
informational · middle
GONNA
informational · middle
GONNA REFERENCE
informational · middle
THE ID
informational · middle
SO NOW
informational · middle
SAMPLE
informational · middle
SAMPLE HUZZ AND
informational · middle
SOME SAMPLE
informational · middle
SHARKS IN THE
informational · middle
AND YOU SEE
informational · middle
AND YOU SEE IF WE
informational · middle
TRY TO ENTER A
informational · middle
SHARK LINK TO THE
informational · middle
SHARK LINK TO THE
informational · middle
HUZZ ID FOUR
informational · middle
BECAUSE
informational · middle
BECAUSE
informational · middle
BECAUSE WE DON'T
informational · middle
BECAUSE WE DON'T
informational · middle
HAVE THE
informational · middle
HAVE THE
informational · middle
BECAUSE WE DON'T
informational · middle
HAVE THE ID
informational · middle
FOUR
informational · middle
IN OUR HUZZ
informational · middle
TABLE
informational · middle
AND NOW
informational · middle
AND NOW WE
informational · middle
AND NOW WE
informational · middle
AND NOW WE
informational · middle
COULD CREATE
informational · middle
THIS QUERY
informational · middle
TO CHECK IF THE
informational · middle
HUZZ
informational · middle
ARE GOING
informational · middle
SO
informational · middle
SO
informational · middle
SO
informational · middle
SO WE WANNA
informational · middle
SO WE WANNA
informational · middle
SELECT THE HUZZ
informational · middle
AND WE WANNA
informational · middle
SHARKS
informational · middle
TO THAT
informational · middle
TO THAT
informational · middle
TO THAT HUZZ ID
informational · middle
THAN
informational · middle
THAN
informational · middle
THAN ONE SHARK
informational · middle
THAT
informational · middle
THAT
informational · middle
THAT
informational · middle
IS
informational · middle
IS
informational · middle
IS
This is how you find out if the huhs are going. If you wanna make sure that you're not sharing the huhs, you gotta be using SQL. So the first thing we gotta do, we're gonna create a table called huhs, and we're gonna store the ID, the first name, and the last name of all the huhs there. There. And we make the ID our primary key. This next part is important to see if the huhs are going. So now we're gonna create another table called sharks. And in the sharks table, we're gonna have the shark name. We're gonna have the hose ID, and the primary key this time is gonna be a combination of the shark name and the HUD's ID. We call this a composite primary key. In the sharks table, we're gonna make our HUD's ID our foreign key, and it's gonna reference the ID column in the HUD's table. So now we're gonna put some sample and some sample sharks in the table. And you see if we try to enter a shark linked to the ID four, we can't because we don't have the ID four in our table. And now we could create this query to check if the are going. So we wanna select the HUDs ID, and we wanna count how many sharks are linked to that HUDs ID. And if it's more than one shark, it means that that HUDs ID is going.