How to use primary keys and foreign keys in Microsoft SQL Server! A brief explanation on what they are as well.
Script used in video:
CREATE TABLE Customers (
CustomerID INT PRIMARY KEY,
Name VARCHAR(100),
Email VARCHAR(100)
);
INSERT INTO Customers (CustomerID, Name, Email) VALUES
(1, 'John Doe', '[email protected]'),
(2, 'Jane Smith', '[email protected]'),
(3, 'Alice Johnson', '[email protected]');
CREATE TABLE Orders (
OrderID INT PRIMARY KEY,
CustomerID INT FOREIGN KEY REFERENCES Customers(CustomerID),
OrderDate DATE,
Amount DECIMAL(10, 2)
);
INSERT INTO Orders (OrderID, CustomerID, OrderDate, Amount) VALUES
(101, 1, '2023-04-21', 150.00),
(102, 2, '2023-04-22', 200.50),
(103, 3, '2023-04-23', 99.99);
Drop a like if you found this video helpful!
Watch video How to Use Primary Keys and Foreign Keys in SQL Server! online without registration, duration hours minute second in high quality. This video was added by user Tech Tips 22 May 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 77 once and liked it 1 people.