Banking Account Management System in SQL
Tables for Account Management and Transaction Insights Case Study.
Customers Table
CustomerID Unique identifier for each customer.
Name Name of the customer.
Email Email of the customer.
Phone Phone number of the customer.
Address Address of the customer.
Accounts Table
AccountID Unique identifier for each account.
CustomerID Unique identifier for the customer who owns the account.
AccountType Type of the account (e.g., Savings, Checking).
Balance Current balance of the account.
Transactions Table
TransactionID Unique identifier for each transaction.
AccountID Unique identifier for the account associated with the transaction.
tDate Date of the transaction.
Amount Amount of the transaction.
TransactionType Type of the transaction (e.g., Deposit, Withdrawal, Transfer).
Creating table and inserting records.
Oracle SQL
Customers Table
CREATE TABLE Customers (
CustomerID NUMBER PRIMARY KEY,
Name VARCHAR2(100) NOT NULL,
Email VARCHAR2(100) UNIQUE,
Phone VARCHAR2(15) NOT NULL,
Address VARCHAR2(255)
);
INSERT INTO Customers (CustomerID, Name, Email, Phone, Address)
VALUES (1, 'John Doe', 'john@example.com', '1234567890', '123 Elm St');
Accounts Table
CREATE TABLE Accounts (
AccountID NUMBER PRIMARY KEY,
CustomerID NUMBER,
AccountType VARCHAR2(20) NOT NULL,
Balance NUMBER DEFAULT 0 CHECK (Balance >= 0),
FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID)
);
INSERT INTO Accounts (AccountID, CustomerID, AccountType, Balance)
VALUES (1, 1, 'Savings', 1500.00);