SQL Databases Flashcards
(100 cards)
What does SQL stand for?
Structured Query Language
SQL is a standard database language developed by IBM in the 1970s.
What is the main purpose of SQL?
To access and manipulate data in databases
SQL can create, update, delete, and retrieve data.
What is a database?
A structured form of data storage in a computer
It includes schemas, tables, queries, views, etc.
Does SQL support programming language features?
False
SQL is a command language and does not include conditional statements like loops.
What is the difference between CHAR and VARCHAR2 data types?
CHAR is fixed length; VARCHAR2 is variable length
Example: CHAR(5) stores 5 characters; VARCHAR2(5) stores up to 5 characters.
What is Data Definition Language (DDL)?
A subset of SQL that defines data structures
Includes commands like CREATE, DROP, and ALTER.
What is Data Manipulation Language (DML)?
A subset of SQL used to manipulate data
Functions include inserting, deleting, retrieving, and updating data.
What is a view in SQL?
A virtual table created from one or more tables
Views can display all or specific rows based on conditions.
What is a foreign key?
A field that uniquely identifies each row in another table
It creates a link between two tables.
What are table and field in SQL?
A table is a combination of rows and columns; a field is a single piece of information
Rows are records, and columns are fields.
What is a primary key?
The most important candidate key in a table
There can only be one primary key per table.
What is a DEFAULT constraint?
Used to fill a column with default values
The default value is added when no other value is provided.
What is normalization?
A process to analyze relation schemas to minimize redundancy and anomalies
It involves decomposing schemas that do not meet desirable properties.
What is denormalization?
A technique to add redundant data to avoid costly joins
It is applied after normalization.
What is a query?
A request to retrieve data from the database
Queries can vary in efficiency.
What is a subquery?
A query within another query
It is typically embedded in the WHERE clause.
What are the different operators available in SQL?
Arithmetic, Logical, and Comparison Operators
These operators allow for various data manipulations.
What is a constraint in SQL?
Rules applied to data types in a table
Constraints limit the type of data stored in specific columns.
What is data integrity?
The correctness and consistency of data in a database
Data must satisfy certain procedures to maintain integrity.
What is Auto Increment?
A feature that automatically generates a unique identifier for new records
It simplifies the process of assigning primary keys.
What is MySQL collation?
A set of rules for comparing characters in a character set
Each character set can have multiple collations.
What are user-defined functions?
Functions created to provide functionality not available in SQL
They can be used in various SQL statements.
What are the types of user-defined functions?
- Scalar User-Defined Function
- Inline Table-Value User-Defined Function
- Multi-statement Table-Value User-Defined Function
Each type serves different purposes in SQL.
What is a stored procedure?
A group of SQL statements that perform DML operations
It accepts parameters and may return a value.