0% found this document useful (0 votes)
17 views17 pages

Data Me

Uploaded by

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

Data Me

Uploaded by

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

University of Sulaimani

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

Submission Date: 2 Dec 2024

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`

-- --------------------------------------------------------

-- Table structure for table `calendar`

CREATE TABLE `calendar` (

`id_cal` int(11) NOT NULL,

`date_start` date NOT NULL,

`date_end` date DEFAULT NULL,

`title` varchar(255) NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Dumping data for table `calendar`

INSERT INTO `calendar` (`id_cal`, `date_start`, `date_end`, `title`) VALUES

(1, '2023-12-01', '2023-12-05', 'Holiday Sale'),

(2, '2024-01-01', NULL, 'New Year Celebration');

-- --------------------------------------------------------

-- Table structure for table `files`

CREATE TABLE `files` (

`id_file` int(11) NOT NULL,

`id_user` int(11) NOT NULL,

`date_modified` datetime DEFAULT NULL,

`title` varchar(255) NOT NULL,

`filename` varchar(255) NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Dumping data for table `files`

INSERT INTO `files` (`id_file`, `id_user`, `date_modified`, `title`, `filename`) VALUES

(1, 1, '2024-12-07 23:09:39', 'Blog Logo', 'logo.png'),

(2, 2, '2024-12-07 23:09:39', 'Sample PDF', 'sample.pdf');

10
-- --------------------------------------------------------

-- Table structure for table `groups`

CREATE TABLE `groups` (

`id_group` int(11) NOT NULL,

`title` varchar(255) NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Dumping data for table `groups`

INSERT INTO `groups` (`id_group`, `title`) VALUES

(1, 'Group A'),

(2, 'Admin'),

(3, 'Editors');

-- --------------------------------------------------------

-- Table structure for table `pages`

CREATE TABLE `pages` (

`id_page` int(11) NOT NULL,

`id_user` int(11) NOT NULL,

`date_modified` datetime DEFAULT NULL,

`title` varchar(255) NOT NULL,

`body` text NOT NULL,

`is_home` tinyint(1) DEFAULT 0

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Dumping data for table `pages`

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);

-- --------------------------------------------------------

-- Table structure for table `posts`

CREATE TABLE `posts` (

`id_post` int(11) NOT NULL,

11
`id_topic` int(11) NOT NULL,

`id_user` int(11) NOT NULL,

`date_created` datetime DEFAULT NULL,

`body` text NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Dumping data for table `posts`

INSERT INTO `posts` (`id_post`, `id_topic`, `id_user`, `date_created`, `body`) VALUES

(1, 1, 1, '2024-12-07 23:09:39', 'Welcome to our blog!'),

(2, 2, 2, '2024-12-07 23:09:39', 'Here are some tips for creating engaging blog content...');

-- --------------------------------------------------------

-- Table structure for table `schedule`

CREATE TABLE `schedule` (

`id_sch` int(11) NOT NULL,

`time_start` time NOT NULL,

`time_end` time NOT NULL,

`weekday` enum('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday') DEFAULT


NULL,

`title` varchar(255) NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Dumping data for table `schedule`

INSERT INTO `schedule` (`id_sch`, `time_start`, `time_end`, `weekday`, `title`) VALUES

(1, '09:00:00', '10:00:00', 'Monday', ' Meeting'),

(2, '15:00:00', '16:00:00', 'Friday', 'Workshop');

-- --------------------------------------------------------

-- Table structure for table `topics`

CREATE TABLE `topics` (

`id_topic` int(11) NOT NULL,

`id_user` int(11) NOT NULL,

`date_modified` datetime DEFAULT NULL,

12
`title` varchar(255) NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Dumping data for table `topics`

INSERT INTO `topics` (`id_topic`, `id_user`, `date_modified`, `title`) VALUES

(1, 1, '2024-12-07 23:09:39', 'Welcome '),

(2, 2, '2024-12-07 23:09:39', 'Home');

-- --------------------------------------------------------

-- Table structure for table `users`

CREATE TABLE `users` (

`id_user` int(11) NOT NULL,

`id_group` int(11) DEFAULT NULL,

`first_name` varchar(100) NOT NULL,

`fam_name` varchar(100) DEFAULT NULL,

`email` varchar(255) NOT NULL,

`pass` varchar(255) NOT NULL,

`about` text DEFAULT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Dumping data for table `users`

INSERT INTO `users` (`id_user`, `id_group`, `first_name`, `fam_name`, `email`, `pass`, `about`) VALUES

(1, 1, 'Lana', 'Ahmed', 'lana.ahmd@****.com', 'lana246', 'Administrator of the blog'),

(2, 2, 'Ali', 'Saman', 'ali.san@****.com', 'ali@90sl', 'Content editor');

-- Indexes for dumped tables

-- Indexes for table `calendar`

ALTER TABLE `calendar`

ADD PRIMARY KEY (`id_cal`);

-- Indexes for table `files`

ALTER TABLE `files`

ADD PRIMARY KEY (`id_file`),

ADD KEY `id_user` (`id_user`);

13
-- Indexes for table `groups`

ALTER TABLE `groups`

ADD PRIMARY KEY (`id_group`);

-- Indexes for table `pages`

ALTER TABLE `pages`

ADD PRIMARY KEY (`id_page`),

ADD KEY `id_user` (`id_user`);

-- Indexes for table `posts`

ALTER TABLE `posts`

ADD PRIMARY KEY (`id_post`),

ADD KEY `id_topic` (`id_topic`),

ADD KEY `id_user` (`id_user`);

-- Indexes for table `schedule`

ALTER TABLE `schedule`

ADD PRIMARY KEY (`id_sch`);

-- Indexes for table `topics`

ALTER TABLE `topics`

ADD PRIMARY KEY (`id_topic`),

ADD KEY `id_user` (`id_user`);

-- Indexes for table `users`

ALTER TABLE `users`

ADD PRIMARY KEY (`id_user`),

ADD UNIQUE KEY `email` (`email`),

ADD KEY `id_group` (`id_group`);

-- AUTO_INCREMENT for dumped tables

-- AUTO_INCREMENT for table `calendar`

ALTER TABLE `calendar`

MODIFY `id_cal` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

-- AUTO_INCREMENT for table `files`

14
ALTER TABLE `files`

MODIFY `id_file` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

-- AUTO_INCREMENT for table `groups`

ALTER TABLE `groups`

MODIFY `id_group` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

-- AUTO_INCREMENT for table `pages`

ALTER TABLE `pages`

MODIFY `id_page` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

-- AUTO_INCREMENT for table `posts`

ALTER TABLE `posts`

MODIFY `id_post` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

-- AUTO_INCREMENT for table `schedule`

ALTER TABLE `schedule`

MODIFY `id_sch` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

-- AUTO_INCREMENT for table `topics`

ALTER TABLE `topics`

MODIFY `id_topic` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

-- AUTO_INCREMENT for table `users`

ALTER TABLE `users`

MODIFY `id_user` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

-- Constraints for dumped tables

-- Constraints for table `files`

ALTER TABLE `files`

ADD CONSTRAINT `files_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `users` (`id_user`);

-- Constraints for table `pages`

ALTER TABLE `pages`

ADD CONSTRAINT `pages_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `users` (`id_user`);

-- Constraints for table `posts`

ALTER TABLE `posts`

15
ADD CONSTRAINT `posts_ibfk_1` FOREIGN KEY (`id_topic`) REFERENCES `topics` (`id_topic`),

ADD CONSTRAINT `posts_ibfk_2` FOREIGN KEY (`id_user`) REFERENCES `users` (`id_user`);

-- Constraints for table `topics`

ALTER TABLE `topics`

ADD CONSTRAINT `topics_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `users` (`id_user`);

-- Constraints for table `users`

ALTER TABLE `users`

ADD CONSTRAINT `users_ibfk_1` FOREIGN KEY (`id_group`) REFERENCES `groups` (`id_group`);

COMMIT;

Designer:

16
Tables:

17

You might also like