Learning Sql libro Flashcards
(30 cards)
¿Qué es SQL y para qué se utiliza?
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.
¿Qué es una base de datos relacional?
What is a relational database?
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.
¿Cuál es la diferencia entre una base de datos y una tabla?
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.
¿Qué significa que SQL es un lenguaje declarativo?
What does it mean that SQL is a declarative language?
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).
¿Qué son las operaciones CRUD y cómo se relacionan con SQL?
What are CRUD operations and how do they relate to SQL?
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.
¿Qué roles desempeñan los RDBMS (Relational Database Management System)?
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.
¿Cuáles son algunos sistemas populares de RDBMS?
Oracle, MySQL, PostgreSQL, SQL Server, DB2, entre otros.
Oracle, MySQL, PostgreSQL, SQL Server, DB2, among others.
¿Qué es un esquema en una base de datos?
What is a schema in a database?
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.
¿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?
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.
¿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?
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.
¿Qué es una clave compuesta y cuándo se recomienda usarla?
What is a composite key and when is it recommended to use one?
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.
¿Qué es un “natural key” y un “surrogate key”?
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).
¿Qué es la normalización/normalization y por qué es importante?
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.
¿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?
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.
¿Cuál es la estructura básica de una tabla en SQL?
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.
¿Qué tipos de datos son comunes en SQL y qué representan?
What are common data types in SQL and what do they represent?
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).
¿Cómo se define una clave primaria (primary key) y por qué es importante?
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.
¿Qué es una restricción de integridad y qué tipos existen?
What is an integrity constraint and what types exist?
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.
¿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?
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) );
¿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?
Usando INSERT INTO tabla (columnas) VALUES (valores).
Using INSERT INTO table_name (columns) VALUES (values).
Ejemplo:
INSERT INTO cliente (
id, nombre) VALUES (1, ‘Juan’);
¿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?
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.
¿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?
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.
¿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?
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.
¿Cuál es la diferencia entre CHAR y VARCHAR?
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.