0% found this document useful (0 votes)
11 views2 pages

DBMS

The document outlines the SQL commands to create a TicketBooking database, including tables for Users, Events, Bookings, and Payments. Each table is defined with relevant fields and relationships, such as foreign keys. Sample data insertion commands for Events and Users tables are also provided.

Uploaded by

sahilekal204
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

DBMS

The document outlines the SQL commands to create a TicketBooking database, including tables for Users, Events, Bookings, and Payments. Each table is defined with relevant fields and relationships, such as foreign keys. Sample data insertion commands for Events and Users tables are also provided.

Uploaded by

sahilekal204
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

-- Create Database

CREATE DATABASE TicketBooking;

-- Use the Database


USE TicketBooking;

-- Users Table
CREATE TABLE Users (
user_id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(100) UNIQUE NOT NULL,
phone VARCHAR(15) NOT NULL,
password VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- Events Table
CREATE TABLE Events (
event_id INT AUTO_INCREMENT PRIMARY KEY,
event_name VARCHAR(100) NOT NULL,
event_date DATE NOT NULL,
location VARCHAR(100) NOT NULL,
available_tickets INT NOT NULL,
ticket_price DECIMAL(10, 2) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- Bookings Table
CREATE TABLE Bookings (
booking_id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
event_id INT NOT NULL,
booking_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
tickets_booked INT NOT NULL,
total_amount DECIMAL(10, 2) NOT NULL,
FOREIGN KEY (user_id) REFERENCES Users(user_id),
FOREIGN KEY (event_id) REFERENCES Events(event_id)
);

-- Payments Table
CREATE TABLE Payments (
payment_id INT AUTO_INCREMENT PRIMARY KEY,
booking_id INT NOT NULL,
payment_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
payment_status ENUM('Pending', 'Completed', 'Failed') DEFAULT 'Pending',
payment_method ENUM('Credit Card', 'Debit Card', 'UPI', 'Net Banking') NOT
NULL,
FOREIGN KEY (booking_id) REFERENCES Bookings(booking_id)
);

-- Example: Insert Data into Events Table


INSERT INTO Events (event_name, event_date, location, available_tickets,
ticket_price)
VALUES
('Rock Concert', '2025-03-15', 'Los Angeles', 100, 150.00),
('Movie Night: Avatar 3', '2025-02-28', 'New York', 200, 50.00),
('Broadway Show: Hamilton', '2025-04-10', 'Chicago', 50, 250.00);

-- Example: Insert Data into Users Table


INSERT INTO Users (name, email, phone, password)
VALUES
('John Doe', '[email protected]', '1234567890', 'securepassword123'),
('Jane Smith', '[email protected]', '0987654321', 'mypassword123');

You might also like