Database Lab Paper Important Topics
(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 Data Types
INT — Whole numbers
VARCHAR(n) — Variable-length text
CHAR(n) — Fixed-length text
DATE — Date values
FLOAT — Decimal numbers
BOOLEAN — True/False values
MS Access Data Types
Short Text — Text up to 255 characters
Long Text — Large text
Number — Numeric values
Date/Time — Dates
Currency — Monetary values
AutoNumber — Auto-incrementing number
Yes/No — Boolean
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
Primary Key vs Unique Key
Primary Key — Only one per table, Cannot be NULL, Enforces uniqueness
Unique Key — Can have multiple, Can have one NULL, Enforces uniqueness
Use Case Diagram
A diagram showing how actors interact with a system via use cases (actions).
Elements:
- Actors
- Use Cases (ovals)
- System Boundary
- Relationships
Implicit Function (in Use Case)
A relationship understood by context but not directly shown on the diagram.
Explicit Function (in Use Case)
A relationship clearly shown in the diagram using lines/arrows.