Last active
December 4, 2015 21:11
-
-
Save FEDE0D/188cc7d3f8651ad4b1ee to your computer and use it in GitHub Desktop.
BBDD1 2015 - Parcial - Ejercicio SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. | |
# creamos el usuario | |
CREATE USER 'u_registrado'@'localhost' IDENTIFIED BY '1234'; | |
# le damos permiso para que lea la tabla noticia | |
GRANT SELECT ON `bd`.`NOTICIA` TO 'u_registrado'@'localhost'; | |
# le damos permiso al usuario para agregar comentarios (no modificar) | |
GRANT INSERT ON `bd`.`COMENTARIO` TO 'u_registrado'@'localhost'; | |
# le damos permiso para modificar los datos de su cuenta | |
GRANT UPDATE ON `bd`.`USUARIO_REGISTRADO` TO 'u_registrado'@'localhost'; | |
2. Utilizaría un trigger. | |
CREATE TRIGGER tr_num_ediciones BEFORE UPDATE ON `bd`.`NOTICIA` | |
FOR EACH ROW | |
SET NEW.numero_de_ediciones = OLD.numero_de_ediciones + 1; | |
3. Utilizaría una transacción. | |
4. | |
* Preprocesamiento de información (evita multiples consultas a la bd). | |
* Tareas repetitivas | |
* Encapsula la logica en un solo modulo. | |
5. | |
* Optimizar consulta (reescribir). Simplificar. Cachear. | |
* Utilizar vistas. | |
* Utilizar los indices correctos. EXPLAIN PLAN, ANALYZE TABLE, SHOW_INDEX | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment