Database Notes
Database Notes
Qn 1: How many field are there I the table above? List them
Qn 2: How many records are there I the table above? List them
• Data types: Classifies how the data is stored, displayed and the operations
that can be performed on the stored values.
• Examples of data types
i. Text/Short text/ Character – stores/ accept text related values.
Note: Text/Short text can accept numbers, letters and special symbols e.g.
Block 2, Makongo Juu.
ii. Number – Stores/ accept number values only.
:types of numbers data types
- Integer stores whole number
- Double stores decimal numbers
iii. Date/Time – stores/accept date and time related values.
iv. Boolean – Stores zero(0) or one(1)
H/w
Write at least five differences between relational database and flat file
database
Key Term Definition
• Attribute – an individual fact, detail or characteristic of an entity (also
commonly called a field).
• Entity – a thing, person, object or relationship about which data can be
collected.
• Primary key (PK) – a unique key/ piece of information within a table to
identify a record.
• Features/ Characteristics of PK
i. PK must be unique
ii. PK must not contain a null value ( PK should not be empty)
• Foreign key (FK) – a field in the table which contains the value of a primary
key in another table (since the primary key is unique this means that the
foreign key identifies, or links to, just one record.
• Redundancy – the duplication of data within a database.
Types of Relationship in database:
1. One to one relationship 1:1
2. One to many relationship
3. Many to many relationship
1:M
1: ∞
M:M
∞:∞
• How to write field names in a table
eg : 1. Student_ID
2. StudentID
eg : First_name
FirstName
NO SPACE WHEN NAMING THE FIELDS.
Types of validation rule
1. Length check – this is used to check how many characters are required
in the field.
2. Format check – Used to check how the filed will be presented/written.
E.g Date format – 27/7/2024
3. Presence check – Used to check if the value has been entered in the
field.
4. Type check – used to check type of value entered e.g number, text
SQL examples
1. SELECT *FROM Student; This will select all the records from the
student table. The use of “ *” means all in SQL.