CREATE DATABASE IF NOT EXISTS realtime_tracker CHARACTER SET utf8mb4 COLLATE utf8mb4_czech_ci;
USE realtime_tracker;

CREATE TABLE users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  username VARCHAR(50) UNIQUE,
  password VARCHAR(255),
  role ENUM('admin','user') DEFAULT 'user'
);

CREATE TABLE locations (
  id INT AUTO_INCREMENT PRIMARY KEY,
  user_id INT,
  latitude DOUBLE,
  longitude DOUBLE,
  timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (user_id) REFERENCES users(id)
);
