-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueries.sql
More file actions
29 lines (29 loc) · 857 Bytes
/
queries.sql
File metadata and controls
29 lines (29 loc) · 857 Bytes
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
/*queries para crear las tablas del post y de los usuarios*/
CREATE TABLE users(
id int NOT NULL AUTO_INCREMENT,
UserName VARCHAR(100),
qualification int,
PRIMARY KEY (id)
);
CREATE TABLE posts(
id int NOT NULL AUTO_INCREMENT,
user_id int,
score int,
workflow text,
createdAt datetime,
coverImage VARCHAR(100),
PRIMARY KEY (id),
FOREIGN KEY (user_id) REFERENCES users(id)
);
/*query para crear la tabla que relaciona los usuarios con los posts*/
CREATE TABLE users_posts(
id int NOT NULL AUTO_INCREMENT,
user_id int NOT NULL,
post_id int NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (user_id) REFERENCES users(id),
FOREIGN KEY (post_id) REFERENCES posts(id)
)
/*query para crear inicialmente 5 usuarios*/
INSERT INTO users (UserName,qualification)
VALUES ('Jose Garcia',5),('Jorge Lopez',4),('Miguel Perez',5)