Learning Sql libro Flashcards

(30 cards)

1
Q

¿Qué es SQL y para qué se utiliza?

A

SQL (Structured Query Language) es un lenguaje para gestionar y manipular bases de datos relacionales. Se usa para crear estructuras, insertar, consultar, actualizar y eliminar datos.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

¿Qué es una base de datos relacional?
What is a relational database?

A

Es un sistema que almacena datos en tablas relacionadas entre sí mediante claves primarias y foráneas.
It is a system that stores data in tables related to each other through primary and foreign keys.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

¿Cuál es la diferencia entre una base de datos y una tabla?

A

Una base de datos contiene múltiples tablas, mientras que una tabla es una colección de filas y columnas que almacena datos específicos.
A database contains multiple tables, while a table is a collection of rows and columns that stores specific data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

¿Qué significa que SQL es un lenguaje declarativo?
What does it mean that SQL is a declarative language?

A

Significa que se indica qué resultado se quiere obtener, pero no cómo lograrlo (el ‘cómo’ lo decide el motor de la base de datos).
It means you specify what result you want to obtain, but not how to achieve it (the how is decided by the database engine).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

¿Qué son las operaciones CRUD y cómo se relacionan con SQL?
What are CRUD operations and how do they relate to SQL?

A

CRUD son las operaciones básicas: Create, Read, Update y Delete. SQL ofrece comandos para cada una: INSERT, SELECT, UPDATE y DELETE.
CRUD refers to the basic operations: Create, Read, Update, and Delete. SQL provides commands for each: INSERT, SELECT, UPDATE, and DELETE.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

¿Qué roles desempeñan los RDBMS (Relational Database Management System)?

A

Los RDBMS almacenan, organizan, procesan y aseguran los datos estructurados; permiten consultas eficientes y control de acceso.
RDBMS store, organize, process, and secure structured data; they enable efficient queries and access control.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

¿Cuáles son algunos sistemas populares de RDBMS?

A

Oracle, MySQL, PostgreSQL, SQL Server, DB2, entre otros.
Oracle, MySQL, PostgreSQL, SQL Server, DB2, among others.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

¿Qué es un esquema en una base de datos?
What is a schema in a database?

A

Es la estructura que define cómo se organizan las tablas, relaciones, vistas, índices y otros objetos en la base de datos.
It is the structure that defines how tables, relationships, views, indexes, and other objects are organized in the database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

¿Por qué es importante conocer SQL incluso si no eres desarrollador?
Why is it important to know SQL even if you are not a developer?

A

Porque muchas herramientas generan SQL detrás de escena, y entenderlo permite personalizar reportes, automatizar tareas y comprender los datos mejor.
Because many tools generate SQL behind the scenes, and understanding it allows customizing reports, automating tasks, and better understanding data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

¿Cuál fue la principal innovación del modelo relacional frente a los modelos jerárquico y de red?
What was the main innovation of the relational model compared to the hierarchical and network models?

A

Eliminar el uso de punteros y reemplazarlos con claves primarias y foráneas, lo que facilitó la normalización y la flexibilidad de las consultas.
Eliminating the use of pointers and replacing them with primary and foreign keys, which facilitated normalization and query flexibility.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

¿Qué es una clave compuesta y cuándo se recomienda usarla?
What is a composite key and when is it recommended to use one?

A

Una clave primaria formada por más de una columna. Se recomienda cuando ninguna columna por sí sola garantiza unicidad.
A primary key composed of more than one column. It is recommended when no single column guarantees uniqueness alone.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

¿Qué es un “natural key” y un “surrogate key”?

A

Una natural key usa datos existentes y significativos; un surrogate key es un identificador artificial sin significado inherente (como un ID numérico).
A natural key uses existing, meaningful data; a surrogate key is an artificial identifier without inherent meaning (like a numeric ID).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

¿Qué es la normalización/normalization y por qué es importante?

A

Es el proceso de organizar datos para reducir la redundancia y mejorar la integridad. Evita inconsistencias y facilita el mantenimiento.
It is the process of organizing data to reduce redundancy and improve integrity. It prevents inconsistencies and eases maintenance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

¿Por qué es preferible almacenar datos separados, como nombre y apellido, en columnas distintas?
Why is it preferable to store data separately, such as first name and last name, in different columns?

A

Para facilitar búsquedas, ordenamientos, y evitar ambigüedades al actualizar o combinar datos.
to facilitate searches, sorting, and avoid ambiguities when updating or combining data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

¿Cuál es la estructura básica de una tabla en SQL?

A

Una tabla está compuesta por filas y columnas; cada columna tiene un tipo de dato y cada fila representa un registro.
A table consists of rows and columns; each column has a data type and each row represents a record.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

¿Qué tipos de datos son comunes en SQL y qué representan?
What are common data types in SQL and what do they represent?

A

Caracteres (CHAR, VARCHAR), números (INT, DECIMAL), fechas (DATE, DATETIME), y textos largos (TEXT, CLOB).
Characters (CHAR, VARCHAR), numbers (INT, DECIMAL), dates (DATE, DATETIME), and long texts (TEXT, CLOB).

17
Q

¿Cómo se define una clave primaria (primary key) y por qué es importante?

A

Usando PRIMARY KEY, se asegura que cada fila tenga un identificador único y no nulo, lo cual permite búsquedas eficientes y relaciones entre tablas.
Using PRIMARY KEY ensures each row has a unique and non-null identifier, allowing efficient searches and table relationships.

18
Q

¿Qué es una restricción de integridad y qué tipos existen?
What is an integrity constraint and what types exist?

A

Son reglas que aseguran la validez de los datos. Tipos comunes: NOT NULL, UNIQUE, CHECK, PRIMARY KEY, FOREIGN KEY.
Rules that ensure data validity. Common types: NOT NULL, UNIQUE, CHECK, PRIMARY KEY, FOREIGN KEY.

19
Q

¿Cómo se crea una tabla en SQL usando la instrucción CREATE TABLE?
How do you create a table in SQL using the CREATE TABLE statement?

A

Con CREATE TABLE nombre (…), se define cada columna con su tipo de dato y restricciones.
With CREATE TABLE table_name (…), defining each column with its data type and constraints.

Ejemplo:
CREATE TABLE cliente (
id INT PRIMARY KEY, nombre VARCHAR(50) );

20
Q

¿Cómo se insertan datos en una tabla con la instrucción INSERT INTO?
How do you insert data into a table using the INSERT INTO statement?

A

Usando INSERT INTO tabla (columnas) VALUES (valores).
Using INSERT INTO table_name (columns) VALUES (values).

Ejemplo:
INSERT INTO cliente (
id, nombre) VALUES (1, ‘Juan’);

21
Q

¿Qué son las claves foráneas (foreign keys) y cómo mantienen la integridad referencial?
What are foreign keys and how do they maintain referential integrity?

A

Son columnas que apuntan a claves primarias de otras tablas, asegurando que los datos estén relacionados correctamente.
Columns that reference primary keys in other tables, ensuring data is correctly related.

22
Q

¿Qué diferencia hay entre NULL y valores como 0 o cadena vacía?
What is the difference between NULL and values like 0 or an empty string?

A

NULL representa un valor desconocido o ausente, mientras que 0 o ‘’ son valores definidos.
NULL represents an unknown or absent value, while 0 or ‘’ are defined values.

23
Q

¿Qué errores comunes se deben evitar al diseñar y poblar una base de datos?
What common mistakes should be avoided when designing and populating a database?

A

Duplicar datos, no definir claves primarias, permitir NULL donde no debería, o insertar datos que violan restricciones.
Duplicating data, not defining primary keys, allowing NULL where it shouldn’t, or inserting data that violates constraints.

24
Q

¿Cuál es la diferencia entre CHAR y VARCHAR?

A

CHAR tiene longitud fija (rellena con espacios); VARCHAR usa longitud variable, optimizando el almacenamiento.
CHAR has fixed length (padded with spaces); VARCHAR uses variable length, optimizing storage.

25
¿Qué es una collation y cómo afecta la comparación de datos?
Es un conjunto de reglas de ordenamiento y comparación de caracteres, importante en búsquedas sensibles a mayúsculas o acentos. It is a set of rules for ordering and comparing characters, important in case- or accent-sensitive searches.
26
¿Qué implica usar un tipo de dato UNSIGNED en una columna numérica?What does using an UNSIGNED data type in a numeric column imply?
Que solo se permiten valores no negativos, lo que duplica el rango positivo permitido. That only non-negative values are allowed, doubling the positive range.
27
¿Cuál es el impacto de usar tipos TEXT o BLOB en una tabla?
Afecta el rendimiento de índices y consultas, ya que estos campos no se manejan igual que los tipos de longitud fija. It affects index and query performance, as these fields are handled differently than fixed-length types.
28
¿Qué tipo de errores pueden ocurrir al insertar datos en una tabla con restricciones? What types of errors can occur when inserting data into a table with constraints?
Violación de clave primaria, clave foránea inexistente, valores NULL no permitidos, o conversión de tipo inválida. Primary key violation, non-existent foreign key, disallowed NULL values, or invalid type conversion.
29
¿Cuál es el propósito del comando SHOW CHARACTER SET en MySQL?
Listar todos los conjuntos de caracteres disponibles para definir columnas que requieran soporte multilingüe. To list all available character sets for defining columns that require multilingual support.
30
¿Por qué deberías evitar almacenar múltiples datos en una sola columna (como dirección completa)? Why should you avoid storing multiple pieces of data in a single column (such as a full address)?
Dificulta la consulta, búsqueda y análisis de los datos individualmente (ej., ciudad o código postal). It makes querying, searching, and analyzing individual data elements (e.g., city or postal code) difficult.