users
جدول المستخدمين الأساسي
id
BIGINT AI PK
name
VARCHAR(255)
email
VARCHAR(255) UNIQUE
email_verified_at
TIMESTAMP NULL
password
VARCHAR(255)
phone
VARCHAR(20) NULL
birthday
DATE NULL
is_active
BOOLEAN DEFAULT 1
created_at
TIMESTAMP
updated_at
TIMESTAMP
categories
تصنيفات المنتجات
id
BIGINT AI PK
name_ar
VARCHAR(255)
name_en
VARCHAR(255)
slug
VARCHAR(255) UNIQUE
icon
VARCHAR(100) NULL
is_active
BOOLEAN DEFAULT 1
sort_order
INT DEFAULT 0
created_at
TIMESTAMP
updated_at
TIMESTAMP
products
جدول المنتجات الرئيسي
id
BIGINT AI PK
name
VARCHAR(255)
sku
VARCHAR(100) UNIQUE
description
TEXT NULL
price
DECIMAL(10,2)
discount_percentage
DECIMAL(5,2) NULL
stock
INT DEFAULT 0
category_id
BIGINT FK
brand_id
BIGINT FK NULL
status
ENUM('active','inactive')
featured
BOOLEAN DEFAULT 0
created_at
TIMESTAMP
updated_at
TIMESTAMP
orders
جدول الطلبات
id
BIGINT AI PK
order_number
VARCHAR(50) UNIQUE
user_id
BIGINT FK
status
ENUM('pending','confirmed','processing','shipped','delivered','cancelled')
total_amount
DECIMAL(10,2)
shipping_amount
DECIMAL(8,2) DEFAULT 0
discount_amount
DECIMAL(8,2) DEFAULT 0
payment_status
ENUM('pending','paid','failed','refunded')
payment_method
VARCHAR(50)
notes
TEXT NULL
created_at
TIMESTAMP
updated_at
TIMESTAMP
user_roles
أدوار المستخدمين
id
BIGINT AI PK
user_id
BIGINT FK
role
ENUM('admin','manager','customer')
assigned_at
TIMESTAMP
shipping_addresses
عناوين الشحن
id
BIGINT AI PK
user_id
BIGINT FK
title
VARCHAR(255) NULL
full_name
VARCHAR(255)
phone
VARCHAR(20)
country
VARCHAR(100)
city
VARCHAR(100)
address_line_1
VARCHAR(500)
is_default
BOOLEAN DEFAULT 0
loyalty_points
نقاط الولاء
id
BIGINT AI PK
user_id
BIGINT FK UNIQUE
points_balance
INT DEFAULT 0
total_earned
INT DEFAULT 0
total_redeemed
INT DEFAULT 0
loyalty_tier
ENUM('bronze','silver','gold','platinum')
brands
العلامات التجارية
id
BIGINT AI PK
name
VARCHAR(255)
slug
VARCHAR(255) UNIQUE
logo
VARCHAR(255) NULL
is_active
BOOLEAN DEFAULT 1
product_images
صور المنتجات
id
BIGINT AI PK
product_id
BIGINT FK
file_path
VARCHAR(500)
alt_text
VARCHAR(255) NULL
sort_order
INT DEFAULT 0
attributes
خصائص المنتجات
id
BIGINT AI PK
name
VARCHAR(255)
type
ENUM('text','number','select','multiselect','boolean')
is_required
BOOLEAN DEFAULT 0
is_filterable
BOOLEAN DEFAULT 0
product_reviews
تقييمات المنتجات
id
BIGINT AI PK
product_id
BIGINT FK
user_id
BIGINT FK
rating
TINYINT(1-5)
comment
TEXT NULL
is_approved
BOOLEAN DEFAULT 0
order_items
عناصر الطلبات
id
BIGINT AI PK
order_id
BIGINT FK
product_id
BIGINT FK
quantity
INT
unit_price
DECIMAL(10,2)
total_price
DECIMAL(10,2)
coupons
كوبونات الخصم
id
BIGINT AI PK
code
VARCHAR(20) UNIQUE
discount_type
ENUM('percentage','fixed')
value
DECIMAL(10,2)
min_order_amount
DECIMAL(10,2) NULL
usage_limit
INT NULL
starts_at
TIMESTAMP NULL
expires_at
TIMESTAMP NULL
is_active
BOOLEAN DEFAULT 1
payment_methods
طرق الدفع
id
BIGINT AI PK
name
VARCHAR(255)
type
ENUM('online','cash','bank_transfer')
gateway
VARCHAR(100) NULL
is_active
BOOLEAN DEFAULT 1
shipping_methods
طرق الشحن
id
BIGINT AI PK
name
VARCHAR(255)
cost
DECIMAL(8,2)
estimated_days
INT
is_active
BOOLEAN DEFAULT 1
علاقات قاعدة البيانات
One-to-Many
users
→
orders
كل مستخدم يمكن أن يكون له عدة طلبات، لكن كل طلب ينتمي لمستخدم واحد فقط.
One-to-Many
categories
→
products
كل تصنيف يمكن أن يحتوي على عدة منتجات، لكن كل منتج ينتمي لتصنيف واحد.
One-to-Many
orders
→
order_items
كل طلب يحتوي على عدة عناصر، وكل عنصر ينتمي لطلب واحد فقط.
One-to-Many
products
→
product_images
كل منتج يمكن أن يكون له عدة صور، وكل صورة تنتمي لمنتج واحد.
One-to-One
users
→
loyalty_points
كل مستخدم له سجل واحد فقط لنقاط الولاء.
Many-to-Many
products
↔
attributes
المنتجات والخصائص لها علاقة متعددة إلى متعددة عبر جدول product_attributes.
One-to-Many
users
→
shipping_addresses
كل مستخدم يمكن أن يكون له عدة عناوين شحن.
One-to-Many
brands
→
products
كل علامة تجارية يمكن أن تحتوي على عدة منتجات.
المخطط البصري لقاعدة البيانات
erDiagram
USERS {
bigint id PK
varchar name
varchar email UK
timestamp email_verified_at
varchar password
varchar phone
date birthday
boolean is_active
timestamp created_at
timestamp updated_at
}
CATEGORIES {
bigint id PK
varchar name_ar
varchar name_en
varchar slug UK
varchar icon
boolean is_active
int sort_order
timestamp created_at
timestamp updated_at
}
PRODUCTS {
bigint id PK
varchar name
varchar sku UK
text description
decimal price
decimal discount_percentage
int stock
bigint category_id FK
bigint brand_id FK
enum status
boolean featured
timestamp created_at
timestamp updated_at
}
ORDERS {
bigint id PK
varchar order_number UK
bigint user_id FK
enum status
decimal total_amount
decimal shipping_amount
decimal discount_amount
enum payment_status
varchar payment_method
text notes
timestamp created_at
timestamp updated_at
}
ORDER_ITEMS {
bigint id PK
bigint order_id FK
bigint product_id FK
int quantity
decimal unit_price
decimal total_price
}
BRANDS {
bigint id PK
varchar name
varchar slug UK
varchar logo
boolean is_active
}
PRODUCT_IMAGES {
bigint id PK
bigint product_id FK
varchar file_path
varchar alt_text
int sort_order
}
PRODUCT_REVIEWS {
bigint id PK
bigint product_id FK
bigint user_id FK
tinyint rating
text comment
boolean is_approved
}
SHIPPING_ADDRESSES {
bigint id PK
bigint user_id FK
varchar title
varchar full_name
varchar phone
varchar country
varchar city
varchar address_line_1
boolean is_default
}
LOYALTY_POINTS {
bigint id PK
bigint user_id FK
int points_balance
int total_earned
int total_redeemed
enum loyalty_tier
}
COUPONS {
bigint id PK
varchar code UK
enum discount_type
decimal value
decimal min_order_amount
int usage_limit
timestamp starts_at
timestamp expires_at
boolean is_active
}
USERS ||--o{ ORDERS : "places"
USERS ||--o{ SHIPPING_ADDRESSES : "has"
USERS ||--|| LOYALTY_POINTS : "has"
USERS ||--o{ PRODUCT_REVIEWS : "writes"
CATEGORIES ||--o{ PRODUCTS : "contains"
BRANDS ||--o{ PRODUCTS : "manufactures"
PRODUCTS ||--o{ ORDER_ITEMS : "ordered_in"
PRODUCTS ||--o{ PRODUCT_IMAGES : "has"
PRODUCTS ||--o{ PRODUCT_REVIEWS : "receives"
ORDERS ||--o{ ORDER_ITEMS : "contains"
مخطط ERD تفاعلي يوضح جميع الجداول والعلاقات في قاعدة بيانات منصة Peak Link