0% found this document useful (0 votes)
2 views

fb code

The document outlines the creation of a database named 'game_db' with three tables: 'players', 'events', and 'messages'. It includes the structure for each table, specifying fields such as player details, event types, and messaging information. Additionally, it details modifications to the 'players' table to include new fields for personal and character information.

Uploaded by

Mohamed Yousef
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

fb code

The document outlines the creation of a database named 'game_db' with three tables: 'players', 'events', and 'messages'. It includes the structure for each table, specifying fields such as player details, event types, and messaging information. Additionally, it details modifications to the 'players' table to include new fields for personal and character information.

Uploaded by

Mohamed Yousef
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

CREATE DATABASE game_db;

USE game_db;

-- ‫جدول الالعبين‬
CREATE TABLE players (
player_id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL,
password VARCHAR(255) NOT NULL,
character_type ENUM('male', 'female') NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- ‫جدول الأحداث‬
CREATE TABLE events (
event_id INT AUTO_INCREMENT PRIMARY KEY,
player_id INT NOT NULL,
event_type VARCHAR(50) NOT NULL,
opponent_id INT,
result ENUM('win', 'lose') NOT NULL,
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (player_id) REFERENCES players(player_id)
);

-- ‫جدول الرسائل‬
CREATE TABLE messages (
message_id INT AUTO_INCREMENT PRIMARY KEY,
player_id INT NOT NULL,
sender_id INT,
message TEXT NOT NULL,
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (player_id) REFERENCES players(player_id)
);

*************

-- ‫تعديل جدول الالعبين لإضافة الحقول الجديدة‬


ALTER TABLE players
ADD COLUMN first_name VARCHAR(50) NOT NULL,
ADD COLUMN last_name VARCHAR(50) NOT NULL,
ADD COLUMN email VARCHAR(100) NOT NULL UNIQUE,
ADD COLUMN country VARCHAR(50) NOT NULL,
ADD COLUMN character_name VARCHAR(50) NOT NULL UNIQUE,
ADD COLUMN mafia_name VARCHAR(50) NOT NULL UNIQUE;
ADD COLUMN profile_picture VARCHAR(255) DEFAULT 'default_profile.png;

ALTER TABLE players


ADD COLUMN profile_picture VARCHAR(255) DEFAULT 'default_profile.png'; -- ‫صورة‬
‫افتراضية‬

You might also like