Podcast
Questions and Answers
What does the % operator do in SQL?
What does the % operator do in SQL?
- It divides two numbers and returns the quotient.
- It returns the integer remainder of a division operation. (correct)
- It compares two values for equality.
- It combines data from two tables.
In the analysis phase of database design, what are attributes?
In the analysis phase of database design, what are attributes?
- Details about the entities. (correct)
- Tables that hold data in the system.
- Relationships between entities.
- Constraints that ensure data integrity.
What SQL command is used to delete rows from a table?
What SQL command is used to delete rows from a table?
- DROP
- CLEAR
- REMOVE
- DELETE (correct)
What is the primary function of the ALTER TABLE command in SQL?
What is the primary function of the ALTER TABLE command in SQL?
Which SQL command is used to create a new table?
Which SQL command is used to create a new table?
Which of the following correctly describes the relationships in the analysis phase of database design?
Which of the following correctly describes the relationships in the analysis phase of database design?
In SQL, what does the TRUNCATE command accomplish?
In SQL, what does the TRUNCATE command accomplish?
What is the effect of using the SET NULL option in SQL?
What is the effect of using the SET NULL option in SQL?
What does the SQL function ABS(n) do?
What does the SQL function ABS(n) do?
Which SQL function would you use to convert a string to lowercase?
Which SQL function would you use to convert a string to lowercase?
What is the purpose of the TRIM(s) function in SQL?
What is the purpose of the TRIM(s) function in SQL?
Which function would return the minute part from a time string?
Which function would return the minute part from a time string?
How is a tuple defined in SQL?
How is a tuple defined in SQL?
What does a table in SQL consist of?
What does a table in SQL consist of?
Which SQL function would you use to extract seconds from a time format?
Which SQL function would you use to extract seconds from a time format?
In the context of SQL, what does an alias represent?
In the context of SQL, what does an alias represent?
What is the function of COUNT() in SQL?
What is the function of COUNT() in SQL?
Which type of JOIN in SQL will include all rows from the right table and only matched rows from the left table?
Which type of JOIN in SQL will include all rows from the right table and only matched rows from the left table?
What is the primary purpose of the UNION operation in SQL?
What is the primary purpose of the UNION operation in SQL?
What does an INNER JOIN specifically select?
What does an INNER JOIN specifically select?
In the context of database design, what does an Entity Relationship Model (ER diagram) primarily focus on?
In the context of database design, what does an Entity Relationship Model (ER diagram) primarily focus on?
What is the primary responsibility of a database administrator?
What is the primary responsibility of a database administrator?
Which SQL data type is used to store integer values?
Which SQL data type is used to store integer values?
What does the Transaction Manager ensure?
What does the Transaction Manager ensure?
Which data type would you use to store a value like 123.45?
Which data type would you use to store a value like 123.45?
Which of the following correctly describes 'Query optimization'?
Which of the following correctly describes 'Query optimization'?
What type of values does the VARCHAR data type store?
What type of values does the VARCHAR data type store?
How many bytes does the INT data type use for storage?
How many bytes does the INT data type use for storage?
Which role is responsible for turning instructions from the Query Processor into file commands?
Which role is responsible for turning instructions from the Query Processor into file commands?
What is the maximum value for an unsigned TINYINT?
What is the maximum value for an unsigned TINYINT?
Which of the following operations can be performed using the addition operator (+)?
Which of the following operations can be performed using the addition operator (+)?
Which type of key is a single-column primary key used when there is no suitable primary key existing?
Which type of key is a single-column primary key used when there is no suitable primary key existing?
What does a Foreign Key reference in a database?
What does a Foreign Key reference in a database?
Which SQL sublanguage is used specifically for controlling user permissions and access?
Which SQL sublanguage is used specifically for controlling user permissions and access?
In the context of aggregate functions, when is the HAVING clause used?
In the context of aggregate functions, when is the HAVING clause used?
What does an Auto-increment column do in a database?
What does an Auto-increment column do in a database?
What is described as a column or group of columns used to uniquely identify a row in a table?
What is described as a column or group of columns used to uniquely identify a row in a table?
Which of the following correctly describes a Composite Primary Key?
Which of the following correctly describes a Composite Primary Key?
In the SQL hierarchy, which language is responsible for defining and setting up the structure of the database?
In the SQL hierarchy, which language is responsible for defining and setting up the structure of the database?
What is an example of a foreign key in a database schema?
What is an example of a foreign key in a database schema?
Which step involves transforming the ER model into specific database structures?
Which step involves transforming the ER model into specific database structures?
What type of table uses a hash function to organize rows into buckets?
What type of table uses a hash function to organize rows into buckets?
Which of the following correctly defines a subtype entity?
Which of the following correctly defines a subtype entity?
What is the primary function of a Materialized View?
What is the primary function of a Materialized View?
Which table structure is characterized by having no specific order for its rows?
Which table structure is characterized by having no specific order for its rows?
In database terminology, what does the term 'cardinality' refer to?
In database terminology, what does the term 'cardinality' refer to?
What is the purpose of an Application Programming Interface (API) in the context of databases?
What is the purpose of an Application Programming Interface (API) in the context of databases?
Flashcards
Database Administrator
Database Administrator
Manages the database's security, controls user access, and ensures data integrity.
Authorization
Authorization
The process of granting permissions to users to access specific data or perform actions within a database.
Rules in a database
Rules in a database
Constraints that enforce data integrity and consistency, ensuring data meets specific criteria and business requirements.
Query Processor
Query Processor
Signup and view all the flashcards
Query Optimization
Query Optimization
Signup and view all the flashcards
Storage Manager
Storage Manager
Signup and view all the flashcards
Transaction Manager
Transaction Manager
Signup and view all the flashcards
INT Data Type
INT Data Type
Signup and view all the flashcards
DECIMAL Data Type
DECIMAL Data Type
Signup and view all the flashcards
VARCHAR Data Type
VARCHAR Data Type
Signup and view all the flashcards
SQL Functions
SQL Functions
Signup and view all the flashcards
ABS(n)
ABS(n)
Signup and view all the flashcards
LOWER(s)
LOWER(s)
Signup and view all the flashcards
TRIM(s)
TRIM(s)
Signup and view all the flashcards
HOUR(t), MINUTE(t), SECOND(t)
HOUR(t), MINUTE(t), SECOND(t)
Signup and view all the flashcards
Tuple
Tuple
Signup and view all the flashcards
Table
Table
Signup and view all the flashcards
Column
Column
Signup and view all the flashcards
Cell
Cell
Signup and view all the flashcards
Literal
Literal
Signup and view all the flashcards
Keyword
Keyword
Signup and view all the flashcards
Identifier
Identifier
Signup and view all the flashcards
Primary Key
Primary Key
Signup and view all the flashcards
Foreign Key
Foreign Key
Signup and view all the flashcards
Data Definition Language (DDL)
Data Definition Language (DDL)
Signup and view all the flashcards
COUNT()
COUNT()
Signup and view all the flashcards
JOIN
JOIN
Signup and view all the flashcards
INNER JOIN
INNER JOIN
Signup and view all the flashcards
ER Diagram
ER Diagram
Signup and view all the flashcards
Equijoin
Equijoin
Signup and view all the flashcards
Entity Type
Entity Type
Signup and view all the flashcards
Relationship Type
Relationship Type
Signup and view all the flashcards
Attribute Type
Attribute Type
Signup and view all the flashcards
Entity Instance
Entity Instance
Signup and view all the flashcards
Relationship Instance
Relationship Instance
Signup and view all the flashcards
Attribute Instance
Attribute Instance
Signup and view all the flashcards
Cardinality
Cardinality
Signup and view all the flashcards
Subtype Entity
Subtype Entity
Signup and view all the flashcards
Unary Minus (-)
Unary Minus (-)
Signup and view all the flashcards
Binary Minus (-)
Binary Minus (-)
Signup and view all the flashcards
Modulo (%)
Modulo (%)
Signup and view all the flashcards
Database Analysis Phase
Database Analysis Phase
Signup and view all the flashcards
Database Logical Design
Database Logical Design
Signup and view all the flashcards
Create Table
Create Table
Signup and view all the flashcards
Insert
Insert
Signup and view all the flashcards
Select
Select
Signup and view all the flashcards
Study Notes
Database Roles
- Database administrators secure the database system from unauthorized users, controlling user access.
- Authorization limits what each user can access.
- Rules ensure the database system maintains structural and business consistency.
- Query processors read and understand queries, creating plans to retrieve or modify data, and returning results to applications.
- Query optimization finds the most efficient way to execute queries.
- Storage managers translate query processor instructions into file commands to retrieve or modify data, using indexes for faster location.
- Transaction managers ensure transactions execute correctly, prevent conflicts between concurrent transactions, and restore the database in case of failure.
SQL Data Types
- INT: Stores integers (positive and negative).
Category | Example | Data Type | Storage | Notes |
---|---|---|---|---|
Integer | 34 and -739448 | TINYINT | 1 byte | Signed: -128 to 127 Unsigned: 0 to 255 |
SMALLINT | 2 bytes | Signed: -32,768 to 32,767 Unsigned: 0 to 65,535 |
||
MEDIUMINT | 3 bytes | Signed: -8,388,608 to 8,388,607 Unsigned: 0 to 16,777,215 |
||
INT | 4 bytes | Signed: -2,147,483,648 to 2,147,483,647 Unsigned: 0 to 4,294,967,295 |
||
BIGINT | 8 bytes | Signed: -263 to 263 -1 Unsigned: 0 to 264 -1 |
Arithmetic and Comparison Operators
- +: Adds two numeric values (e.g., 4 + 3 = 7).
- -: Reverses the sign of a numeric value (e.g., -(-2) = 2).
- -: Subtracts one numeric value from another (e.g., 11 - 5 = 6).
- %: Returns the integer remainder of a division (e.g., 5 % 2 = 1).
- =: Compares for equality (e.g., 1 = 2 is FALSE).
-
: Compares using greater than (e.g., '2019-08-13' > '2021-08-13' is FALSE).
- !=: Compares for inequality (e.g., 1 != 2).
Database Design Phases
- Analysis: Outlines database needs, focusing on entities (things or people), relationships between entities, and attributes (details about entities).
- Logical Design: Converts database requirements into a specific system format (tables, columns, keys).
- Physical Design: Optimizes data retrieval speed by adding indexes to data tables.
SQL Commands
- CREATE TABLE: Creates a table (e.g.,
CREATE TABLE employees (...)
). - INSERT INTO: Inserts new rows into a table (e.g.,
INSERT INTO employees
). - SELECT: Retrieves data from a table (e.g.,
SELECT first_name, last_name FROM employees
). - UPDATE: Modifies data within a table (e.g.,
UPDATE employees SET salary = 55000 WHERE employee_id = 101
). - DELETE FROM: Removes rows from a table (e.g.,
DELETE FROM employees WHERE employee_id = 101
). - ALTER TABLE: Modifies existing tables (adding or deleting columns) (e.g.,
ALTER TABLE employees ADD phone_number VARCHAR(15)
).
SQL Operators
- BETWEEN: Checks if a value falls within a specified range.
- LIKE: Matches text against a pattern in a column. Uses '%' for multiple characters and '_' for single characters.
- Alias: Temporary names assigned to table columns (e.g.,
SELECT first_name AS "First Name"
).
SQL Functions
- ABS(n): Returns the absolute value of a number.
- LOWER(s): Converts a string to lowercase.
- TRIM(s): Removes leading and trailing spaces from a string.
- HOUR(t), MINUTE(t), SECOND(t): Extracts the hour, minute, and second from a time value.
Data Structure
- Tuple: Ordered collection of elements.
- Table: Stores data with columns and rows.
- Column: Holds data of a specific type (e.g., number, text).
- Row: Holds values for each column.
- Cell: A single column within a row.
SQL Elements
- Literals: Explicit string, numeric, or binary values.
- Keywords: Words with special meaning (e.g., SELECT, FROM, WHERE).
- Identifiers: Objects in the database (e.g., tables, columns).
- Primary Key: Column uniquely identifying a row.
- Simple Primary Key: Single column.
- Composite Primary Key: Multi-column.
- Artificial Key: Single-column primary key created when no other suitable key exists.
- Candidate Key: Simple or composite column that uniquely identifies a row (and is minimal).
- Auto-Increment Column: Numeric column that automatically increases with each new row.
- Foreign Key: References a primary key (crucial for relational connections).
SQL Sublanguages
- DDL(Data Definition Language): Defines database structure (e.g., creating tables).
- DQL (Data Query Language): Retrieves data from the database (e.g., SELECT).
- DML (Data Manipulation Language): Manipulates table data (e.g., INSERT, UPDATE, DELETE).
- DCL (Data Control Language): Controls user permissions (e.g., GRANT, REVOKE).
- DTL (Data Transaction Language): Manages database transactions (e.g., COMMIT, ROLLBACK).
Aggregate Functions
- COUNT(): Counts rows.
- MIN(): Finds the minimum value.
- MAX(): Finds the maximum value.
- SUM(): Computes the sum of values.
- AVG(): Computes the average of values.
JOIN and Union in SQL
- Join combines data from multiple tables (e.g., INNER JOIN, FULL JOIN, LEFT JOIN, RIGHT JOIN, OUTER JOIN, UNION).
- Equijoins use =, non-equijoins (e.g., <, >).
- Cross-join combines data from two tables without matching based on columns.
Entity Relationship Model (ERM)
- ER diagram defines entity relations/links.
- Entities represent real-world objects (e.g., employees, products).
- Relationships show how entities interact (e.g., employee to department).
- Attributes of Entities provide details about entities.
- Instances are specific instances of entities.
- Relationships are defined by Instances between entities.
Table Structures
- Heap table: No specific order for rows (useful for bulk loading).
- Sorted table: Ordered by a column for fast lookups.
- Hash table: uses a hash to place rows into buckets for quick lookup.
- Table cluster: Reduces data access times by grouping related tables together.
Other Definitions
- API (Application Programming Interface): Allows different programs to communicate and interact.
- SQL Client: Text-based interface for interacting with the database.
- Business Rules: Policies used within a database (specific to the system).
- Subquery (Nested Query/Inner Query): SQL query nested within another query.
- Materialized View: a stored representation of a query's result set.
- Cardinality: Shows maximum and minimum values of entity relations.
- Subtype Entity: set of related entities within a larger supertype.
- Normalization: Reduces data redundancy by creating different tables.
- Denormalization: Increases redundancy in a database for improved efficiency.
- Hit Ratio: Percentage of results retrieved from a database.
- Binary Search: A way to locate matching data in a sorted database.
- Dense and Sparse Index: Different indexing methods with varying storage characteristics.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Test your knowledge of essential SQL commands and concepts, including data manipulation, table management, and attributes in database design. This quiz covers various SQL functions and operators that are critical for effective database management.