Database Lab Notes
Database Lab Notes
(Revised)
Primary Key
A unique identifier for each record in a table. Cannot be null, no duplicate values.
Example:
CREATE TABLE Students (
ID INT PRIMARY KEY,
Name VARCHAR(50)
);
Foreign Key
A field in one table that refers to the Primary Key of another table, creating a relationship.
Candidate Key
A column (or set) that can uniquely identify records. One becomes the Primary Key.
Composite Key
A combination of two or more columns used together as a Primary Key.
SQL Queries
CREATE TABLE — Create a table
INSERT INTO — Add new data
SELECT — Retrieve data
UPDATE — Change data
DELETE — Remove data
Relationships in MS Access
One-to-One — 1 record in Table A to 1 in Table B
One-to-Many — 1 record in Table A to many in Table B