-- Customers table
CREATE TABLE customers (
    customer_id INTEGER PRIMARY KEY,
    name TEXT NOT NULL,
    age INTEGER,
    city TEXT,
    email TEXT
);

-- Accounts table
CREATE TABLE accounts (
    account_id INTEGER PRIMARY KEY,
    customer_id INTEGER,
    account_type TEXT CHECK(account_type IN ('Savings', 'Current', 'Loan')),
    balance REAL,
    opened_on DATE,
    FOREIGN KEY (customer_id) REFERENCES customers(customer_id)
);

-- Sample data: customers
INSERT INTO customers (customer_id, name, age, city, email) VALUES (1, 'John Doe', 30, 'New York', 'john.doe@example.com');
INSERT INTO customers (customer_id, name, age, city, email) VALUES (2, 'Jane Smith', 25, 'Los Angeles', 'jane.smith@example.com');
INSERT INTO customers (customer_id, name, age, city, email) VALUES (3, 'Michael Johnson', 45, 'Chicago', 'michael.j@example.com');
INSERT INTO customers (customer_id, name, age, city, email) VALUES (4, 'Emily Davis', 28, 'Houston', 'emily.davis@example.com');
INSERT INTO customers (customer_id, name, age, city, email) VALUES (5, 'David Wilson', 35, 'Phoenix', 'david.w@example.com');

-- Sample data: accounts
INSERT INTO accounts (account_id, customer_id, account_type, balance, opened_on) VALUES (1, 1, 'Savings', 1000.50, '2023-01-15');
INSERT INTO accounts (account_id, customer_id, account_type, balance, opened_on) VALUES (2, 2, 'Savings', 500.75, '2022-11-20');
INSERT INTO accounts (account_id, customer_id, account_type, balance, opened_on) VALUES (3, 3, 'Current', 2500.00, '2023-03-10');
INSERT INTO accounts (account_id, customer_id, account_type, balance, opened_on) VALUES (4, 4, 'Loan', -10000.00, '2021-06-01');
INSERT INTO accounts (account_id, customer_id, account_type, balance, opened_on) VALUES (5, 5, 'Savings', 350.00, '2024-04-25');
INSERT INTO accounts (account_id, customer_id, account_type, balance, opened_on) VALUES (6, 1, 'Loan', -5000.00, '2022-05-10');
INSERT INTO accounts (account_id, customer_id, account_type, balance, opened_on) VALUES (7, 2, 'Current', 700.00, '2023-08-12');
