Practical SQL Examples for Database Management

Student and Course Database Examples

Database Creation

It’s good practice to create a dedicated database for your tables.

-- Create a new database (optional, good practice)
CREATE DATABASE IF NOT EXISTS StudentDB;
USE StudentDB;

Table Creation

Here, we define the Student and Course tables. Note the use of PRIMARY KEY, FOREIGN KEY, NOT NULL, UNIQUE, and CHECK constraints.

CREATE TABLE Student (
    StudentID INT PRIMARY KEY AUTO_INCREMENT,
    Name VARCHAR(100) NOT NULL,
    Dept VARCHAR(50),
    Age INT,
Read More

Java JDBC MySQL CRUD: Data Manipulation Examples

Java JDBC CRUD: MySQL Database Interaction

This document provides practical Java code examples demonstrating basic CRUD (Create, Read, Update, Delete) operations on a MySQL database using JDBC (Java Database Connectivity).

Each example connects to a local MySQL database named mydb with user root and an empty password. It’s important to note that for production environments, using PreparedStatement is highly recommended to prevent SQL injection vulnerabilities, and sensitive credentials should not

Read More

Advanced SQL Queries for Database Analytics

This document presents a collection of practical SQL queries designed to extract valuable insights from a database, likely a music store schema such as Chinook. Each query demonstrates different SQL concepts, from basic data retrieval to complex joins, subqueries, and aggregations, providing solutions for common business questions.

  1. Top 10 Customers by Spending (Over $40)

    Identifies the top 10 customers who have spent more than $40 in total, ordered by their total expenditure in descending order.

    SELECT 
Read More

SQL Database Design & Query Examples

Library Database Schema Definition

This section outlines the SQL Data Definition Language (DDL) statements for creating a library database, including tables for publishers, distributors, customers, articles, books, journals, and rental records.

Database Setup

DROP DATABASE IF EXISTS library;
CREATE DATABASE IF NOT EXISTS library;
USE library;

Table Creation Statements

Below are the DDL statements for defining the various tables within the library database, establishing relationships and constraints.

Publisher

Read More

Linux Server Network Services Setup

DNS and DHCP Installation Exercise

This document outlines the steps to install and configure essential network services on a Linux server, including DNS (BIND), DHCP, HTTPD (Apache), and VSFTPD.

DNS Server Configuration (BIND)

1. Install BIND Packages

Begin by installing the necessary BIND packages using yum:

[root@localhost ~]# yum -y install bind bind-chroot bind-libs caching-nameserver

2. Configure BIND Named.conf

Edit the main BIND configuration file to define your DNS zones:

[root@localhost ~]# vi 
Read More

Computer Fundamentals: Hardware, Software, and Data Processing

Computer Basics: Definitions and Types

What is a Computer?

An electronic device designed for performing operations on data at high speed.

Computer Types

  • Desktop: The monitor and computer (tower) are separated. Non-portable.
  • Laptop: The monitor and computer are integrated. Portable.

Core Computing Concepts

Hardware

The physical computer and its parts.

Software

Digital instructions to be run by the computer.

  • Program: A piece of software.
  • Operating System: A program for running other programs.

BIOS (Basic Input/

Read More