-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.sql
96 lines (88 loc) · 3.64 KB
/
db.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
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
-- Volcando estructura de base de datos para social_network
CREATE DATABASE IF NOT EXISTS `social_network` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `social_network`;
-- Volcando estructura para tabla social_network.countries
CREATE TABLE IF NOT EXISTS `countries` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`country` varchar(55) NOT NULL,
`createdAt` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Volcando estructura para tabla social_network.cities
CREATE TABLE IF NOT EXISTS `cities` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`city` int(11) NOT NULL,
`country_id` int(11) NOT NULL,
`createdAt` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
FOREIGN KEY (country_id) REFERENCES countries(id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Volcando estructura para tabla social_network.users
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`first_name` varchar(50) NOT NULL,
`last_name` varchar(50) NOT NULL,
`email` varchar(50) NOT NULL,
`password` varchar(50) NOT NULL,
`profile_image` varchar(255) DEFAULT NULL,
`description` varchar(255) DEFAULT NULL,
`city_id` int(11) DEFAULT NULL,
`age` int(2) DEFAULT NULL,
`status` boolean DEFAULT true,
`createdAt` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`),
FOREIGN KEY (city_id) REFERENCES cities(id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Volcando estructura para tabla social_network.friends
CREATE TABLE IF NOT EXISTS `friends` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id1` int(11) NOT NULL,
`user_id2` int(11) NOT NULL,
`status` boolean DEFAULT true,
`createdAt` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
FOREIGN KEY (user_id1) REFERENCES users(id),
FOREIGN KEY (user_id2) REFERENCES users(id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Volcando estructura para tabla social_network.posts
CREATE TABLE IF NOT EXISTS `posts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`content` text NOT NULL,
`image` varchar(255) DEFAULT NULL,
`status` boolean DEFAULT true,
`createdAt` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
FOREIGN KEY (user_id) REFERENCES users(id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Volcando estructura para tabla social_network.comments
CREATE TABLE IF NOT EXISTS `comments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`post_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`content` text NOT NULL,
`status` boolean DEFAULT true,
`createdAt` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
FOREIGN KEY (post_id) REFERENCES posts(id),
FOREIGN KEY (user_id) REFERENCES users(id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Volcando estructura para tabla social_network.likes
CREATE TABLE IF NOT EXISTS `likes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`post_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`status` boolean DEFAULT true,
`createdAt` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
FOREIGN KEY (post_id) REFERENCES posts(id),
FOREIGN KEY (user_id) REFERENCES users(id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;