Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
1 views

my database mysql

Uploaded by

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

my database mysql

Uploaded by

cyrusmaylan27
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

-- Create the database

CREATE DATABASE cartmeat_db;

USE cartmeat_db;

-- Table: Accounts (stores shared login credentials for admins and customers)

CREATE TABLE tbl_accounts (

account_id INT AUTO_INCREMENT PRIMARY KEY,

username VARCHAR(50) NOT NULL UNIQUE,

password VARCHAR(255) NOT NULL,

role ENUM('admin', 'customer') NOT NULL,

created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

);

CREATE TABLE tbl_admin (

admin_id INT AUTO_INCREMENT PRIMARY KEY,

account_id INT NOT NULL,

first_name VARCHAR(50),

last_name VARCHAR(50),

email VARCHAR(100) NOT NULL UNIQUE,

contact_number VARCHAR(15),

address TEXT NULL, -- Nullable address field

status TINYINT(1) DEFAULT 1, -- Status: 1 = active, 0 = inactive

created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

FOREIGN KEY (account_id) REFERENCES tbl_accounts(account_id) ON DELETE CASCADE


);

CREATE TABLE tbl_customers (

customer_id INT AUTO_INCREMENT PRIMARY KEY,

account_id INT NOT NULL,

first_name VARCHAR(50),

last_name VARCHAR(50),

email VARCHAR(100) NOT NULL UNIQUE,

contact_number VARCHAR(15),

address TEXT NULL, -- Nullable address field

age INT NULL, -- Nullable age field

gender ENUM('male', 'female', 'other') NULL, -- Nullable gender field

marital_status ENUM('single', 'married', 'divorced', 'widowed') NULL, -- Nullable marital status

status TINYINT(1) DEFAULT 1, -- Status: 1 = active, 0 = inactive

created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

FOREIGN KEY (account_id) REFERENCES tbl_accounts(account_id) ON DELETE CASCADE

);

-- Table: Profile Images (stores profile images for both admins and customers)

CREATE TABLE tbl_profile_image (

image_id INT AUTO_INCREMENT PRIMARY KEY,

account_id INT NOT NULL,

image_url VARCHAR(255) NOT NULL,


uploaded_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

FOREIGN KEY (account_id) REFERENCES tbl_accounts(account_id) ON DELETE CASCADE

);

You might also like