Databases
Databases
WHAT IS A DATABASE?
• TEXT / ALPHANUMERIC
• Stores letters, numbers, and symbols.
• Examples: Names, addresses, or descriptions.
• CHARACTER
• Stores a single letter or symbol.
• Example: Gender field with 'M' or 'F’.
• BOOLEAN
• Stores true/false or yes/no values.
• Example: IsEnrolled field where True = Enrolled, False = Not Enrolled.
BASIC DATA TYPES IN DATABASES
• INTEGER
• Stores whole numbers.
• Examples: Age, quantity, or number of items.
• REAL
• Stores decimal numbers for precise values.
• Examples: Price, height, or weight.
• DATE / TIME
• Stores dates and/or times.
• Examples: Date of birth, appointment time, or order date.
• Standard Date Format- YYYY-MM-DD or MM-DD-YYYY
• Time format – HH:MI:SS
EXAMPLE OF A DATA TYPE SELECTION
Date of IsGraduate
• For a Student Database: Name Age
Enrollment d
• Name: Text Alice 2022-08-
21 False
Johnson 15
• Age: Integer
2021-06-
• Date of Enrollment: Date Bob Smith 23 True
01
• IsGraduated: Boolean 2023-01-
Charlie Lee 22 False
10
Diana 2020-09-
25 True
Brown 20
Emma 2022-05-
24 False
Davis 05
ACTIVITY 1: DETERMINE THE RIGHT DATA
TYPE
CONCEPT OF A PRIMARY KEY
• A primary key is a unique identifier for each record (row) in a database table.
• Ensures that every entry in the table is distinct and can be referenced
individually.
• Primary keys prevent duplicate records and ensure data integrity.
• Characteristics of a Primary Key:
• Unique: No two records can have the same primary key value.
• Non-Null: Every record must have a primary key value (it cannot be empty).
• );
EXAMPLE OF A SQL QUERY