Database
Database Theory And Concepts
Database Basics
A database is a collection of data organized to make it easy to store, retrieve, manipulate, and
manage records. Electronic databases are used in systems including medical records management,
online streaming services, student management information systems, and social media platforms.
Traditional paper-based databases have limitations. A physical file might be misplaced. Searching for
a specific file takes a long time.
Tables, Fields, And Records
A database table is a collection of rows and columns. A field is a space for a particular piece of
information about an entity. A record is a group of fields related to an entity. A data dictionary is a
table showing the name of each field, its data type, and other metadata.
Data Types
Data types tell the computer how the data will be used.
Data Type Explanation
Integer Holds discrete values or whole numbers.
Real Represents data containing a decimal point.
Text Holds a string of characters.
Boolean Holds values that are either True or False.
Date/Time Holds values representing a date and time.
Primary Keys
A primary key is a field that uniquely identifies each record in a database table. A primary key cannot
have the same value for two or more records.
Database Queries Using Structured Query Language
Selecting Data
Structured query language is used to retrieve data from a database. The SELECT statement specifies
the fields you want to view from the database table. The FROM statement specifies the table name.
An asterisk selects all fields in the specified table.
SQL Statement Explanation
SELECT FieldName Retrieves all values from a single field
FROM TableName in the database.
SELECT FieldName1, FieldName2 Retrieves two fields from the
FROM TableName database.
SELECT * FROM TableName Selects all the fields in the specified
database table.
Filtering Data
The WHERE clause retrieves data that meets a specified criterion. Text values in the criteria require
speech marks. Multiple conditions use the AND operator when both criteria must be met. The OR
operator is used when either one or both criteria must be met.
Operator Meaning
= Equal to.
<> Not equal to.
< Less than.
> Greater than.
<= Less than or equal to.
>= Greater Than Or Equal To.
Sorting Data
The ORDER BY statement sorts the retrieved data in ascending or descending order. The keyword
DESC sorts the output in descending order. By default, data is sorted in ascending order.
Calculating Data
The Sum operation calculates the sum of values in a specified field that meet a certain criterion. The
COUNT operation counts the number of records that meet a given condition.