Express + MySQL CRUD API for student records, with a plain HTML frontend. - Single-file backend (server.js) with 5 CRUD routes - Proper HTTP status codes and a consistent error envelope - 8-digit ids: 2-digit year + per-year 6-digit counter (e.g. 26000001), allocated under a MySQL advisory lock so concurrent inserts cannot collide - student_db.sql schema and seed data - .env for credentials; only .env.example is committed
25 lines
706 B
SQL
25 lines
706 B
SQL
-- student_db schema and seed data.
|
|
|
|
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
|
START TRANSACTION;
|
|
SET time_zone = "+00:00";
|
|
SET NAMES utf8mb4;
|
|
|
|
DROP TABLE IF EXISTS `students`;
|
|
|
|
CREATE TABLE `students` (
|
|
`id` int NOT NULL,
|
|
`name` varchar(100) NOT NULL,
|
|
`course` varchar(50) NOT NULL,
|
|
`year_level` int NOT NULL,
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
|
|
|
-- Ids are a 2-digit year + a per-year counter, so these two were added in 2026.
|
|
-- The app assigns ids, so there is no AUTO_INCREMENT here.
|
|
INSERT INTO `students` (`id`, `name`, `course`, `year_level`) VALUES
|
|
(26000001, 'Juan Dela Cruz', 'BSIT', 2),
|
|
(26000002, 'Maria Santos', 'BSCS', 3);
|
|
|
|
COMMIT;
|