DATA BASE – is a well-organized compilation of data that enables
individuals to retrieve information according to their specific
requirements.
The data contained within a database can encompass various forms
such as text, numerical values, images, or any other type of digital
content that can be stored on a computer system.
Type of database
1. Flat file database (Non Relational database)-data are stored in a
single large table known as flat file. Eg Ms Excel
2. Relational database – data are stored in more than one table where
the table can be linked /relate one another.
Where Relational database can be created?
Relational database can be created on DBMS( Database Management
System)- is the software for creating a relational database.
Eg.Ms Access, Oracle, MySql, SQL Server etc.
What makes a database/ database components/ database objects/
database elements.
1. Table – where data are stored
2. Forms – is used to capture information from the user to the database.
( Used to enter data in the database)
3. Reports – it is used to present information to user from the database.
4. Query – is the request for a specific information from the database.
Eg SQL (Structured Query Language)
Table structure
Table is made up of Rows and Columns
i. Field – is a collection of related characters. It is represented by
column in table. Eg Name, Address, Age, mobile…
ii. Record – is the collection of related field. It is represented by row in a
table.
Fields First Name Sirname Age Address
Juma Bakari 14 Kinondoni
Ephron Malawa 2 Makongo
Records
Evan Malawa 4 Mlimani City
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.
2. SELECT First_name, Last_name, Gender FROM Student; This will
retrieve only the records of the mentioned fields from the table.