-- Create Users Table
CREATE TABLE Users (
    user_id INT PRIMARY KEY,           -- Unique identifier for each user
    signup_date DATE NOT NULL           -- Date when the user signed up
);

-- Create Transactions Table
CREATE TABLE Transactions (
    transaction_id INT PRIMARY KEY,      -- Unique transaction identifier
    user_id INT,                         -- References Users table
    transaction_date DATE NOT NULL,      -- Date when the transaction occurred
    transaction_amount DECIMAL(10,2) NOT NULL,  -- Amount of the transaction
    CONSTRAINT fk_user FOREIGN KEY (user_id) REFERENCES Users(user_id) ON DELETE CASCADE
);

-- Insert data into Users table
INSERT INTO Users (user_id, signup_date) VALUES
(1, '2024-01-10'),
(2, '2024-02-15'),
(3, '2024-03-20'),
(4, '2024-04-05'),
(5, '2024-05-12');

-- Insert data into Transactions table
INSERT INTO Transactions (transaction_id, user_id, transaction_date, transaction_amount) VALUES
(101, 1, '2024-06-01', 100.00),
(102, 1, '2024-06-10', 200.50),
(103, 2, '2024-06-05', 150.75),
(104, 2, '2024-06-15', 300.00),
(105, 3, '2024-06-07', 500.25),
(106, 3, '2024-06-17', 250.00),
(107, 4, '2024-06-20', 400.00),
(108, 4, '2024-06-25', 100.00),
(109, 5, '2024-06-30', 50.00);  -- Only one transaction (should be excluded in the query)
 
by