DB Projecct
DB Projecct
UNIVERSITY
GROUP MEMBER ID
1.Getahun Million UGE/27697/14
Database project
wegenu
1. ER-diagram
2 Data Definition Language (DDL) queries using
Microsoft SQL
create database Banking
use Banking
create table customers(
cust_id char(12) primary key,
Fname varchar(20),
Lname varchar(30),
sex varchar(2),
addres varchar(200),
date_of_birth date,
Email varchar(100) ,
tax_identifier varchar(20)
)
create table branch(
B_name varchar(200),
B_code char(12) primary key,
[B_address] varchar(100),
)
create table Employee(
Employe_id char(12) primary key,
Fname varchar(30),
Lname varchar(30),
sex varchar(2),
addres varchar(100),
salary decimal(9,2),
position varchar(100),
B_code char(12) foreign key references branch(B_code )
)
create table Account(
Account_id char(12) primary key,
Account_type varchar(20),
Account_no varchar(20),
Current_Balance decimal(30,2),
Date_opened datetime,
date_closed datetime,
Account_status varchar(40),
Cust_id char(12) foreign key references customers(cust_id),
B_code char(12) foreign key references Branch(B_code )
)
select * from Account
4.scenario
Seppose you want to create database for bank , the bank include- The "branch"
table is populated with branch information. Two branches are added with their
names, branch codes, and addresses.
- Employee details are inserted into the "Employee" table. Two employees are
added with their IDs, names, genders, addresses, salaries, positions, and
corresponding branch codes.
- Account information is added to the "Account" table. Two accounts are created
with account IDs, types (such as savings or checking), account numbers, current
balances, opening dates, closing dates (if applicable), account statuses, customer
IDs, and branch codes.
- The "loan" table stores loan details. Two loans are created with loan IDs, types
(e.g., home loan or auto loan), loan amounts, interest rates, loan terms, start dates,
end dates, statuses, and customer IDs.
- Loan payment information is added to the "Loan_payment" table. Two loan
payments are created with payment IDs, scheduled payment dates, payment
amounts, principal amounts, interest amounts, paid amounts, paid dates, and
corresponding loan IDs.
. Sample Scenario:
- The scenario starts by inserting customer information into the "customers"
table. Two customers are added with their respective details, including names,
addresses, dates of birth, email addresses, and tax identifiers.
- Transactions are recorded in the "Transactions" table. Two transactions are
added with transaction IDs, types (such as deposit or withdrawal), transaction
amounts, transaction dates, loan payment IDs (if applicable), account IDs, and
employee IDs.
- Customer-account relationships are established in the "Customer_Account"
table. Two entries are made to associate customer IDs with account IDs.
- Phone numbers of customers, employees, and branches are stored in the
"customer_phone", "Employe_phone", and "Branch_phone" tables, respectively.
Each phone number is linked to the corresponding customer, employee, or branch
through their respective IDs.
This sample scenario showcases the basic usage of the database schema, allowing
you to store and retrieve data related to customers, branches, employees, accounts,
loans, transactions, and phone numbers. You can expand upon this scenario by
adding more data or implementing additional functionalities as per your banking
system's requirements.
--6.security