1
0
mirror of https://github.com/actix/examples synced 2024-11-27 16:02:57 +01:00

simplify sql create tables

This commit is contained in:
Rob Ede 2023-07-18 01:09:09 +01:00
parent 048f4fd884
commit 16bfb1cf2f
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
11 changed files with 31 additions and 35 deletions

View File

@ -18,11 +18,11 @@ $ pwd
The `sql` directory contains the SQL files used for database setup:
```sh
mysql -u root -p < sql/create_database.sql
mysql -u root -p my_bank < sql/bank_details.sql
mysql -u root -p my_bank < sql/branch_details.sql
mysql -u root -p my_bank < sql/teller_details.sql
mysql -u root -p my_bank < sql/customer_details.sql
mysql -u root -p < sql/0_create_database.sql
mysql -u root -p my_bank < sql/1_bank_details.sql
mysql -u root -p my_bank < sql/2_branch_details.sql
mysql -u root -p my_bank < sql/3_teller_details.sql
mysql -u root -p my_bank < sql/4_customer_details.sql
```
For each step you will be prompted for the root user's password. If there's no password set on the root use, just hit enter again.

View File

@ -0,0 +1,6 @@
CREATE TABLE `bank_details` (
`id` BIGINT AUTO_INCREMENT PRIMARY KEY,
`bank_name` VARCHAR(30) NOT NULL,
`country` VARCHAR(30) NOT NULL,
`date_added` DATETIME DEFAULT CURRENT_TIMESTAMP
) CHARSET=utf8mb4;

View File

@ -0,0 +1,6 @@
CREATE TABLE `branch_details` (
`id` BIGINT AUTO_INCREMENT PRIMARY KEY,
`branch_name` VARCHAR(30) NOT NULL,
`location` VARCHAR(30) NOT NULL,
`date_added` DATETIME DEFAULT CURRENT_TIMESTAMP
) CHARSET=utf8mb4;

View File

@ -0,0 +1,6 @@
CREATE TABLE `customer_details` (
`id` BIGINT AUTO_INCREMENT PRIMARY KEY,
`customer_name` VARCHAR(100) NOT NULL,
`branch_name` VARCHAR(30) NOT NULL,
`date_added` DATETIME DEFAULT CURRENT_TIMESTAMP
) CHARSET=utf8mb4;

View File

@ -0,0 +1,6 @@
CREATE TABLE `teller_details` (
`id` BIGINT AUTO_INCREMENT PRIMARY KEY,
`teller_name` VARCHAR(100) NOT NULL,
`branch_name` VARCHAR(30) NOT NULL,
`date_added` DATETIME DEFAULT CURRENT_TIMESTAMP
) CHARSET=utf8mb4;

View File

@ -1,7 +0,0 @@
CREATE TABLE `bank_details` (
`id` int NOT NULL AUTO_INCREMENT,
`bank_name` VARCHAR(30) DEFAULT '',
`country` VARCHAR(30) DEFAULT '',
`date_added` DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;

View File

@ -1,7 +0,0 @@
CREATE TABLE `branch_details` (
`id` int NOT NULL AUTO_INCREMENT,
`branch_name` VARCHAR(30) DEFAULT '',
`location` VARCHAR(30) DEFAULT '',
`date_added` DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;

View File

@ -1,7 +0,0 @@
CREATE TABLE `customer_details` (
`id` INT NOT NULL AUTO_INCREMENT,
`customer_name` VARCHAR(100) DEFAULT '',
`branch_name` VARCHAR(30) DEFAULT '',
`date_added` DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;

View File

@ -1,7 +0,0 @@
CREATE TABLE `teller_details` (
`id` int NOT NULL AUTO_INCREMENT,
`teller_name` varchar(100) DEFAULT '',
`branch_name` varchar(30) DEFAULT '',
`date_added` datetime DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;

View File

@ -30,7 +30,7 @@ CREATE TABLE `product` (
PRIMARY KEY (`id`),
KEY `product_fk0` (`user_id`),
CONSTRAINT `product_fk0` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
) ENGINE=InnoDB CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@ -55,7 +55,7 @@ CREATE TABLE `user` (
`email` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
) ENGINE=InnoDB CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--