Client-Server Architecture
MySQL client-server architecture
MySQL runs as a server on port 3306. Clients (Workbench, phpMyAdmin, PHP PDO) send SQL over TCP or socket; the server executes and returns results.
In hotel_db the PHP web app is a client — it never reads database files directly. Many clients access gosti and rezervacije concurrently. In hotel_db reception, finance, and housekeeping share gosti, sobe, rezervacije, placanja, and zaposleni — every change must stay consistent for all app modules.
In depth
Authentication uses user, password, and per-database privileges. Root is for admin only; the app uses a limited hotel_db account. In Workbench run the sample SQL on test data before production, check EXPLAIN as tables grow, and document expected results for teammates.
Key points
- Server stores data and runs SQL. — hotel_db example.
- Client displays results. — hotel_db example.
- Default port 3306. — hotel_db example.
- Separate app users. — hotel_db example.
- No direct file access. — hotel_db example.
Practical example
Terminal connection.
mysql -h localhost -u root -pCommon mistake
Using root in PHP because it is easier. Typical fallout: mismatched reception vs finance data, lost reservations, or blocked check-ins at peak season — always backup before production DDL/DML.
Summary
Understanding client-server is the basis of secure hotel_db work. Practice again on hotel_db until you can explain every result row and tie it to hotel workflows (check-in, billing, reporting).
Note: Tip: keep versioned .sql scripts (hotel_schema.sql, seed.sql) in Git — reproducibility matters when several people work on the same hotel_db model.
