-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrowdfundingdb.sql
More file actions
109 lines (94 loc) · 3.98 KB
/
crowdfundingdb.sql
File metadata and controls
109 lines (94 loc) · 3.98 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
-- MySQL Script generated by MySQL Workbench
-- 4 Aprili 2024 11:50:41 alasiri
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
-- -----------------------------------------------------
-- Schema crowdfunding
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema crowdfunding
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `crowdfunding` DEFAULT CHARACTER SET utf8 ;
USE `crowdfunding` ;
-- -----------------------------------------------------
-- Table `crowdfunding`.`campaignCategory`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `crowdfunding`.`campaignCategory` (
`category_id` INT AUTO_INCREMENT NOT NULL,
`category_name` VARCHAR(45) NULL,
PRIMARY KEY (`category_id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `crowdfunding`.`images`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `crowdfunding`.`images` (
`image_id` INT AUTO_INCREMENT NOT NULL,
`image_url` VARCHAR(500) NULL,
PRIMARY KEY (`image_id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `crowdfunding`.`campaigns`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `crowdfunding`.`campaigns` (
`campaign_id` INT AUTO_INCREMENT NOT NULL,
`campaign_title` VARCHAR(45) NULL,
`campaign_description` TEXT(2000) NULL,
`target_amount` INT NOT NULL,
`funding_deadline` DATE NOT NULL, -- Use DATE datatype for date fields,
`industry` VARCHAR(45) NULL,
`is_active` VARCHAR(45) NULL,
`current_amount` INT(45) NULL,
`creator_id` INT NOT NULL,
PRIMARY KEY (`campaign_id`),
FOREIGN KEY (`creator_id`) REFERENCES `users`(`user_id`)
)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `crowdfunding`.`campaign_images`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `crowdfunding`.`campaignImages` (
`campaign_images_id` INT AUTO_INCREMENT NOT NULL,
`campaign_id` INT NOT NULL,
`image_id` INT NOT NULL,
FOREIGN KEY (`campaign_id`) REFERENCES `crowdfunding`.`campaigns`(`campaign_id`),
FOREIGN KEY (`image_id`) REFERENCES `crowdfunding`.`images`(`image_id`),
PRIMARY KEY (`campaign_images_id`)
)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `crowdfunding`.`users`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `crowdfunding`.`users` (
`user_id` INT AUTO_INCREMENT NOT NULL,
`username` VARCHAR(45) NOT NULL,
`email` VARCHAR(100) NOT NULL,
`password` VARCHAR(255) NOT NULL,
`location` VARCHAR(100) NULL,
`registration_date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`account_type` ENUM('investor', 'entrepreneur', 'admin') NOT NULL,
PRIMARY KEY (`user_id`),
UNIQUE KEY `email_UNIQUE` (`email`)
)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `crowdfunding`.`transactions`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `crowdfunding`.`transactions` (
`transaction_id` INT AUTO_INCREMENT NOT NULL,
`payment_method` VARCHAR(45) NULL,
`transaction_date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`transaction_status` VARCHAR(45) NULL,
`transaction_amount` DECIMAL(10, 2) NOT NULL,
`sender_id` INT NOT NULL,
`campaign_id` INT NOT NULL,
PRIMARY KEY (`transaction_id`),
FOREIGN KEY (`sender_id`) REFERENCES `users`(`user_id`),
FOREIGN KEY (`campaign_id`) REFERENCES `campaigns`(`campaign_id`)
)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;