Mayilov Semender Database
Mayilov Semender Database
COURSE WORK
Contents
1.1 Introduction………………………………………..…............….......
1.2 ER diagram……………………………………………..…................
3.1 SQL select, order by, where command, update, delete statements......
Conclusion………….......………………..….......................................…………..
Bank database
1.1 Introduction
The current banking system operates at a slower pace as most tasks are performed
manually, which cannot match the efficiency of computer-based processes. The
system's complexity grows significantly with an increasing number of customers,
leading to a rise in transactions. Logging all these activities manually for future
reference is cumbersome and outdated. Such drawbacks are substantial enough to
impact the overall functionality of the banking system. By adopting digital
solutions, banks can not only meet their operational goals but also gain advantages,
such as reducing the need for manual calculations.
1.2 ER Diagram
The ER (Entity-Relationship) diagram illustrates the structure of the Bank
Management System. It visually represents the database tables and the
relationships among entities like branches, employees, customers, and accounts.
This diagram is essential for organizing structured data and defining the
connections between various functional components of the system. The key
features of the Bank Management System Database Design include managing
customer, employee, branch, account, and bank card information effectively.
Creating tables in the bank database
Tables are utilized to store data within a database. To create a basic table, you must
specify the table's name, define its columns, and determine the data type for each
column. The SQL CREATE TABLE statement is used to define and create a new
table. To add new rows of data into an existing table, the INSERT INTO statement
in SQL Server is used.
BirthDate DATE,
Salary DECIMAL(6,2),
HireDate DATE
);
VALUES
1. Table Creation:
o The Employee table is created with columns such as Id, BranchId,
DepartmentId, Name, Surname, BirthDate, Email, PhoneNumber,
Salary, and HireDate.
o BranchId and DepartmentId are foreign keys referencing the Branch
and Department tables respectively.
2. Inserting Data:
o Four rows of data are inserted into the Employee table with
Azerbaijani names and other details such as birthdate, email, phone
number, salary, and hire date.
3. Selecting Data:
o The SELECT * FROM Employee; query fetches all the records from
the Employee table.
2.2 Alter, drop columns
Explanation of Changes:
1) Employee Table
2) Department Table
CREATE TABLE Department (
Id INT PRIMARY KEY IDENTITY,
Name NVARCHAR(50) NOT NULL
);
3) Bank Table
4) Address Table
5) Branch Table
);
7) Position Table
9) AccountType Table
2. Query to find the name and surname of the customer with the ID number 4
UPDATE Card
SET CVV = 843
WHERE Number = '5455001240856770';
2. Query to find the name, surname of customers and type and balance of
accounts opened on '2021-12-20' or '2021-12-21':
4. Query to find the name, surname, email, date of birth, and department of
employees born in the 1990s:
FROM Employee;
Joining tables
1. INNER JOIN to obtain the name, surname of the employees and their
account type and balance:
FROM Customer c
2. LEFT JOIN to obtain the name and surname of the customers and the address
of the branch where they were registered:
FROM Branch b
3. RIGHT JOIN to find the name, surname of the employees and the
department, position they are in:
FROM Employee e
FROM Employee e
GROUP BY d.Name
FROM Employee e
SQL Subqueries
1. Query to obtain the balance and the date when the account was opened,
associated with the card numbers specified:
FROM Account a
WHERE a.Id IN (
SELECT AccountId
FROM Card
);
3. Query to find the name, surname, and salary of the employee who gets the
highest salary:
FROM Employee e
CONCLUSION