-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminiprojectcreate.sql
57 lines (50 loc) · 1.3 KB
/
miniprojectcreate.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
CREATE DATABASE IF NOT EXISTS miniproject_mysql;
USE miniproject_mysql;
DROP TABLE IF EXISTS Transactions;
DROP TABLE IF EXISTS Cards;
DROP TABLE IF EXISTS Accounts;
DROP TABLE IF EXISTS Employees;
DROP TABLE IF EXISTS Customers;
DROP TABLE IF EXISTS Branches;
CREATE TABLE Customers (
CustomerId INT PRIMARY KEY,
Firstname VARCHAR(255),
Lastname VARCHAR(255),
Email VARCHAR(255)
);
CREATE TABLE Branches (
BranchId INT PRIMARY KEY,
Branchname VARCHAR(255),
Branchaddress VARCHAR(255),
Branchmail VARCHAR(255)
);
CREATE TABLE Accounts (
AccountId INT PRIMARY KEY,
CustomerId INT,
Accountname VARCHAR(255),
Balance INT,
FOREIGN KEY (CustomerId) REFERENCES Customers(CustomerId)
);
CREATE TABLE Cards (
CardId INT PRIMARY KEY,
CustomerId INT,
Cardlimit INT,
Debt INT,
Cardtype VARCHAR(255),
FOREIGN KEY (CustomerId) REFERENCES Customers(CustomerId)
);
CREATE TABLE Employees (
StaffId INT PRIMARY KEY,
BranchId INT,
Empname VARCHAR(255),
Empsurname VARCHAR(255),
Email VARCHAR(255),
Position VARCHAR(255),
FOREIGN KEY (BranchId) REFERENCES Branches(BranchId)
);
CREATE TABLE Transactions (
TransactionId INT PRIMARY KEY,
AccountId INT,
Amount INT,
FOREIGN KEY (AccountId) REFERENCES Accounts(AccountId)
);