Database Software Basics
Database Software Basics
A database is an organized collection of data that is stored and managed to make it easy to access, update,
and manipulate. It is designed to efficiently handle large amounts of information and is typically managed
by a Database Management System (DBMS).
Examples of Databases: A library catalog, employee records, banking systems, and online retail websites.
2. Table
• Records (Rows): Each row represents a single data entity or instance (e.g., a single customer in a
customer database).
• Fields (Columns): Each column represents a specific attribute of the data (e.g., a customer’s name or
phone number).
3. Primary Key
A primary key is a column (or set of columns) in a table that uniquely identifies each row. It ensures that
no duplicate values exist for this column.
Purpose: To establish the unique identity of a record (e.g., a unique ID for a student).
SQL is the standard language used to interact with relational databases. SQL commands are categorized
based on their functionality. Here are two primary types:
DDL commands define or modify the structure of database objects like tables, indexes, and schemas. These
commands affect the schema and are not used to manipulate data directly.
DML commands deal with the manipulation of data stored in database tables. These commands allow you
to retrieve, insert, update, or delete data.
1
Lecturer: Zishan Ahmed Introduction to Computers (Final-term Notes)
1. Creating a Table
Name VARCHAR(50),
Age INT,
Department VARCHAR(20),
GPA FLOAT,
ScholarshipAmount FLOAT
);
2. Inserting Data
VALUES
3. Querying Data
2
Lecturer: Zishan Ahmed Introduction to Computers (Final-term Notes)
c) Select only Name and GPA for Students with GPA > 3.6
Name GPA
Alice 3.8
Charlie 3.7
Eve 3.9
Frank 3.6
Name GPA
Daisy 3.4
Bob 3.5
Frank 3.6
Charlie 3.7
Alice 3.8
Eve 3.9
Name GPA
Eve 3.9
Alice 3.8
Charlie 3.7
3
Lecturer: Zishan Ahmed Introduction to Computers (Final-term Notes)
Frank 3.6
Bob 3.5
Daisy 3.4
f) Select all the fields for the student with the name ‘Daisy’
Aggregate Functions
MAX(ScholarshipAmount)
2000.0
MIN(ScholarshipAmount)
800.0
AVG(ScholarshipAmount)
1266.67
SUM(ScholarshipAmount)
7600.0
4. Updating Data
UPDATE Students
WHERE StudentID = 1;
4
Lecturer: Zishan Ahmed Introduction to Computers (Final-term Notes)
VALUES
6. Deleting Data