Está en la página 1de 2

Table users {

id SERIAL [pk, increment]


created_at TIMESTAMP
updated_at TIMESTAMP
username VARCHAR(30)
bio VARCHAR(400)
avatar VARCHAR(200)
phone VARCHAR(25)
email VARCHAR(40)
password VARCHAR(50)
status VARCHAR(15)
}

Table posts {
id SERIAL [pk, increment]
created_at TIMESTAMP
updated_at TIMESTAMP
url VARCHAR(200)
user_id INTEGER [ref: > users.id]
caption VARCHAR(240)
lat REAL
lng REAL
}

Table comments {
id SERIAL [pk, increment]
created_at TIMESTAMP
updated_at TIMESTAMP
contents VARCHAR(240)
user_id INTEGER [ref: > users.id]
post_id INTEGER [ref: > posts.id]
}

Table likes {
id SERIAL [pk, increment]
created_at TIMESTAMP
contents VARCHAR(240)
user_id INTEGER [ref: > users.id]
comment_id INTEGER [ref: > comment.id]
post_id INTEGER [ref: > posts.id]
}

Table caption_tags {
id SERIAL [pk, increment]
created_at TIMESTAMP
user_id INTEGER [ref: > users.id]
post_id INTEGER [ref: > posts.id]
}

Table photo_tags {
id SERIAL [pk, increment]
created_at TIMESTAMP
updated_at TIMESTAMP
user_id INTEGER [ref: > users.id]
post_id INTEGER [ref: > posts.id]
x INTEGER
y INTEGER
}
Table hashtags {
id SERIAL [pk, increment]
created_at TIMESTAMP
title VARCHAR(20)
}

Table hashtags_posts {
id SERIAL [pk, increment]
post_id INTEGER [ref: > posts.id]
hashtag_id INTEGER [ref: > hashtags.id]
}

Table followers {
id SERIAL [pk, increment]
created_at TIMESTAMP
leader_id INTEGER [ref: > users.id]
follower_id INTEGER [ref: > users.id]
}

En función de estas estructuras, realizar los scripts necesarios para:


1.- Generar tablas en una base de datos con nombre apellido_Deber1
2.- Generar Diagrama Entidad - Relación
3.- Registrar al menos 10 registros en cada tabla
4.- Realizar las siguientes consultas:
4.1.- Cuente el número de usuarios sobre la tabla del mismo nombre
4.2.- Cuente el número de usuarios sobre la tabla del mismo nombre que han sido
creados entre 2020 y 2022
4.3.- Obtenga el promedio de post por usuario
4.4.- Cuente los comentarios por usuario
4.5.- Liste los 3 seguidores con más seguidores
4.6.- Cuente las fotos del usuario con más post
4.7.- Liste los usuarios con más fotos (muestre el número de fotos)

También podría gustarte