Aprovecha el precio especial y haz tu profesión a prueba de IA

Antes: $249

Currency
$209
Suscríbete

Termina en:

0 Días
14 Hrs
45 Min
11 Seg
Curso de SQL y MySQL

Curso de SQL y MySQL

Genaro Bernardino

Genaro Bernardino

Diseño y Optimización Avanzada de Bases de Datos con SQL y MySQL

1/19
Resources
Transcript

Database management is a fundamental skill that has evolved significantly over the past few decades. From basic operations to advanced functionality, MySQL offers a robust set of tools that can transform the way we interact with our data. This content explores advanced features that empower our databases, allowing us to create more efficient solutions and make decisions based on accurate, up-to-date information.

What makes this advanced MySQL course special?

This course represents the culmination of years of hands-on experience in the database world. Unlike the fundamentals course, here we will delve into more advanced concepts that will transform your understanding of MySQL and allow you to take advantage of its full potential. It's not just about storing data, it's about making it work intelligently for you.

Among the topics we will cover are:

  • Triggers to automate responses to events.
  • Generating views to simplify complex queries
  • Generated columns that automatically calculate values
  • JSON column type implementation
  • Techniques to simulate materialized views

These insights are applicable not only for developers, but also for data scientists, executives and CTOs who need to understand the capabilities and limitations of their storage systems.

How can generated columns transform the way we work?

One of the most powerful features of MySQL is the ability to create generated columns. These columns are automatically calculated from existing values in other columns, without the need to store redundant data.

Let's see a practical example with a simple sales table:

CREATE TABLE sales ( id INT AUTO_INCREMENT PRIMARY KEY, date DATE, price FLOAT, quantity INT, total FLOAT GENERATED ALWAYS AS (price * quantity) VIRTUAL);

In this example, the total column is automatically generated by multiplying price by quantity. The fascinating thing is that this column does not occupy disk space, since it is calculated in real time when requested.

We can insert data normally, without worrying about the total field:

INSERT INTO sales (date, price, quantity) VALUES('2023-06-12', 15.5, 3),('2023-06-12', 20.0, 1),('2023-06-15', 45.5, 1);

When querying the table, MySQL automatically calculates the totals:

SELECT * FROM sales;

This functionality eliminates the need for repetitive calculations in our applications and ensures consistency of the derived data.

What are views and how can they simplify our complex queries?

Views are stored queries that behave like virtual tables. They are especially useful when we need to frequently execute complex queries or when we want to provide a simplified interface to users.

For example, if we want to regularly analyze daily sales, we could create a view like this:

CREATE VIEW daily_sales ASSELECT date, SUM(total) AS totalFROM salesGROUP BY dateORDER BY date ASC;

Once created, we can query this view as if it were a normal table:

SELECT * FROM sales_daily_sales;

Or even apply additional conditions:

SELECT * FROM sales_daily_sales WHERE total > 45;

Views allow us to encapsulate complexity and provide clean interfaces to access our data, facilitating analysis and decision making.

Why are these advanced features important?

These advanced MySQL features go beyond simple data storage. They allow you to create databases that are more intelligent, robust and easier to exploit. They transform a simple repository into a powerful decision-making tool.

Key benefits include:

  • Reduced "noise" in the data, making it easier to focus on what is important.
  • Increased consistency in calculations and analysis
  • Simplification of interaction with the database
  • Improved performance by avoiding repetitive calculations
  • Ease of sharing information between different users and roles.

These functionalities allow us to take full advantage of the data we collect in our applications, transforming it into valuable information to make smarter decisions.

Modern databases are much more than simple information containers; they are dynamic tools that can radically transform the efficiency of our systems. As we progress through this course, we will discover how to leverage the full potential of MySQL to create more elegant and effective solutions. What other advanced MySQL features have you used in your projects? Share your experience in the comments.

Contributions 10

Questions 4

Sort by:

Want to see more contributions, questions and answers from the community?

Becco, Que bueno tener otro curso tuyo, Excelente
Me cae perfecto este curso ahora 🙌
Wenas
Si también les surgió la duda como a mí, creo que el curso de fundamentos que comenta el profesor es este: <https://platzi.com/cursos/sql-mysql2018/> Me corrigen si estoy mal. Saludos.
🚀 **¿Quieres llevar tus tablas de MySQL al siguiente nivel?** Aquí te dejo una forma poderosa de crear **columnas calculadas automáticamente** usando `GENERATED ALWAYS AS` 💡 CREATE TABLE ventas ( ventas\_id INT UNSIGNED PRIMARY KEY AUTO\_INCREMENT, fecha DATE NOT NULL, precio FLOAT, cantidad INT NOT NULL DEFAULT 1, total FLOAT GENERATED ALWAYS AS (precio \* cantidad) VIRTUAL ); 🤔 **¿Qué hace esta magia?** * `total` **no se guarda físicamente** en la tabla: se calcula automáticamente al consultar. * Es una columna **VIRTUAL**, así que **no ocupa espacio en disco**. * Te ayuda a mantener tus datos consistentes y sin errores de cálculo. 📌 Perfecto para reportes en tiempo real sin cargar tu base de datos.
Es lo que estaba esperando.
Muy bueno!
Excelente! Nuevos videos con el conocimiento actualizado. Gracias profe, clase 1 con muchas expectativas.
wu
¡Interesante!