Data Me
Data Me
College of Commerce
Information Technology Department
2nd Stage – 1st Semester
Subject:Database
Submitted By
Mihraban Faxir Braim
Honia Kamaran Latif
Arkan Najeeb Raheem
Zhyar Adnan Hassan
Supervised by
Mr. Bilal Rashid
2024-2025
Table of Contents
Banking transaction:......................................................................................3
Bank Management System Scenario..........................................................3
SQL Code:....................................................................................................4
Designer:.......................................................................................................8
Tables:...........................................................................................................8
Blog system:.....................................................................................................9
Blogging System Scenario:..........................................................................9
SQL code:...................................................................................................10
Designer:.....................................................................................................16
Tables:.........................................................................................................17
2
Banking transaction:
Bank Management System Scenario :is a structured design to handle the core functions of banking,
focusing on customers, branches, and their transactions, such as deposits, withdrawals, and loans. The
design is based on the relationships between these entities, ensuring that all interactions are well-
organized and scalable for real-world banking operations.
Entities and Their Roles:
1. Customer
The Customer entity represents the individuals who interact with the bank to access financial services.
Each customer has a unique identifier to distinguish them from others. Additional attributes, such as their
name, Social Security Number (SSN), and address, are included to store essential personal and contact
information. Customers are the core users of the banking system, as they initiate deposits, withdrawals,
and loan transactions.
2. Branch
The Branch entity represents the physical or virtual locations of the bank where services are offered. Each
branch has its own unique identifier, name, and address, along with an affiliation attribute that defines
whether it is a corporate or independent branch. Branches act as service points for customers and are
responsible for managing all customer transactions.
3. Deposit
The Deposit entity records the transactions in which customers deposit money into their accounts. Each
deposit transaction is uniquely identified and linked to both a customer and a branch. The attributes
include the account number associated with the deposit and the balance held in the account. Deposits
form one of the primary services provided by the bank.
4. Withdrawal
The Withdrawal entity captures transactions where customers withdraw money from their accounts.
Similar to deposits, withdrawals are uniquely identified and linked to specific customers and branches.
The account number and balance attributes help track the flow of funds and ensure accurate record-
keeping for each withdrawal.
5. Loan
The Loan entity represents the loans issued to customers. This entity is uniquely identified by a loan ID
and is linked to both the customer receiving the loan and the branch managing it. The attributes include
the account number and the outstanding loan balance. Loans are a critical component of banking
operations and require detailed tracking for repayment schedules and branch accountability
3
SQL Code:
-- Database: `bank`
-- --------------------------------------------------------
-- Table structure for table `branch`
CREATE TABLE `branch` (
`BranchID` int(11) NOT NULL,
`Name` varchar(100) NOT NULL,
`Address` varchar(255) NOT NULL,
`Affiliation` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
-- Table structure for table `customer`
CREATE TABLE `customer` (
`CustomerID` int(11) NOT NULL,
`Name` varchar(100) NOT NULL,
`SSN` varchar(11) NOT NULL,
`Address` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
-- Table structure for table `deposit`
CREATE TABLE `deposit` (
`DepositID` int(11) NOT NULL,
`CustomerID` int(11) NOT NULL,
`BranchID` int(11) NOT NULL,
`AccountNumber` varchar(20) NOT NULL,
`Balance` decimal(15,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
4
-- Table structure for table `loan`
CREATE TABLE `loan` (
`LoanID` int(11) NOT NULL,
`CustomerID` int(11) NOT NULL,
`BranchID` int(11) NOT NULL,
`AccountNumber` varchar(20) NOT NULL,
`Balance` decimal(15,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
-- Table structure for table `withdrawal`
CREATE TABLE `withdrawal` (
`WithdrawalID` int(11) NOT NULL,
`CustomerID` int(11) NOT NULL,
`BranchID` int(11) NOT NULL,
`AccountNumber` varchar(20) NOT NULL,
`Balance` decimal(15,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- Indexes for dumped tables
-- Indexes for table `branch`
ALTER TABLE `branch`
ADD PRIMARY KEY (`BranchID`);
-- Indexes for table `customer`
ALTER TABLE `customer`
ADD PRIMARY KEY (`CustomerID`),
ADD UNIQUE KEY `SSN` (`SSN`);
-- Indexes for table `deposit`
ALTER TABLE `deposit`
ADD PRIMARY KEY (`DepositID`),
ADD UNIQUE KEY `AccountNumber` (`AccountNumber`),
ADD KEY `CustomerID` (`CustomerID`),
5
ADD KEY `BranchID` (`BranchID`);
-- Indexes for table `loan`
ALTER TABLE `loan`
ADD PRIMARY KEY (`LoanID`),
ADD UNIQUE KEY `AccountNumber` (`AccountNumber`),
ADD KEY `CustomerID` (`CustomerID`),
ADD KEY `BranchID` (`BranchID`);
-- Indexes for table `withdrawal`
ALTER TABLE `withdrawal`
ADD PRIMARY KEY (`WithdrawalID`),
ADD UNIQUE KEY `AccountNumber` (`AccountNumber`),
ADD KEY `CustomerID` (`CustomerID`),
ADD KEY `BranchID` (`BranchID`);
-- AUTO_INCREMENT for dumped tables
-- AUTO_INCREMENT for table `branch`
ALTER TABLE `branch`
MODIFY `BranchID` int(11) NOT NULL AUTO_INCREMENT;
-- AUTO_INCREMENT for table `customer`
ALTER TABLE `customer`
MODIFY `CustomerID` int(11) NOT NULL AUTO_INCREMENT;
-- AUTO_INCREMENT for table `deposit`
ALTER TABLE `deposit`
MODIFY `DepositID` int(11) NOT NULL AUTO_INCREMENT;
-- AUTO_INCREMENT for table `loan`
ALTER TABLE `loan`
MODIFY `LoanID` int(11) NOT NULL AUTO_INCREMENT;
-- AUTO_INCREMENT for table `withdrawal`
ALTER TABLE `withdrawal`
MODIFY `WithdrawalID` int(11) NOT NULL AUTO_INCREMENT;
6
-- Constraints for dumped tables
ALTER TABLE `deposit`
ADD CONSTRAINT `deposit_ibfk_1` FOREIGN KEY (`CustomerID`) REFERENCES `customer`
(`CustomerID`),
ADD CONSTRAINT `deposit_ibfk_2` FOREIGN KEY (`BranchID`) REFERENCES `branch`
(`BranchID`);
ALTER TABLE `loan`
ADD CONSTRAINT `loan_ibfk_1` FOREIGN KEY (`CustomerID`) REFERENCES `customer`
(`CustomerID`),
ADD CONSTRAINT `loan_ibfk_2` FOREIGN KEY (`BranchID`) REFERENCES `branch`
(`BranchID`);
-- Constraints for table `withdrawal`
ALTER TABLE `withdrawal`
ADD CONSTRAINT `withdrawal_ibfk_1` FOREIGN KEY (`CustomerID`) REFERENCES `customer`
(`CustomerID`),
ADD CONSTRAINT `withdrawal_ibfk_2` FOREIGN KEY (`BranchID`) REFERENCES `branch`
(`BranchID`);
COMMIT;
7
Designer:
Tables:
8
Blog system:
Blogging System Scenario:
9
SQL code:
-- Database: `blogsystems`
-- --------------------------------------------------------
-- --------------------------------------------------------
10
-- --------------------------------------------------------
(2, 'Admin'),
(3, 'Editors');
-- --------------------------------------------------------
INSERT INTO `pages` (`id_page`, `id_user`, `date_modified`, `title`, `body`, `is_home`) VALUES
(1, 1, '2024-12-07 23:09:39', 'Home Page', ' Explore our posts and pages.', 1),
(2, 2, '2024-12-07 23:09:39', 'About Us', 'We are a team of passionate bloggers.', 0);
-- --------------------------------------------------------
11
`id_topic` int(11) NOT NULL,
(2, 2, 2, '2024-12-07 23:09:39', 'Here are some tips for creating engaging blog content...');
-- --------------------------------------------------------
-- --------------------------------------------------------
12
`title` varchar(255) NOT NULL
-- --------------------------------------------------------
INSERT INTO `users` (`id_user`, `id_group`, `first_name`, `fam_name`, `email`, `pass`, `about`) VALUES
13
-- Indexes for table `groups`
14
ALTER TABLE `files`
15
ADD CONSTRAINT `posts_ibfk_1` FOREIGN KEY (`id_topic`) REFERENCES `topics` (`id_topic`),
COMMIT;
Designer:
16
Tables:
17