Podcast
Questions and Answers
Which SQL command is responsible for retrieving data from a database?
Which SQL command is responsible for retrieving data from a database?
- INSERT INTO
- DELETE
- SELECT (correct)
- UPDATE
When using SQL, what is the correct syntax to delete data from a table named 'Customers' where the 'CustomerID' is 123?
When using SQL, what is the correct syntax to delete data from a table named 'Customers' where the 'CustomerID' is 123?
- DELETE TABLE Customers WHERE CustomerID = 123;
- DROP FROM Customers WHERE CustomerID = 123;
- DELETE FROM Customers WHERE CustomerID = 123; (correct)
- REMOVE FROM Customers WHERE CustomerID = 123;
What is the correct SQL command to create a new table named 'Employees' with columns for 'EmployeeID', 'FirstName', and 'LastName'?
What is the correct SQL command to create a new table named 'Employees' with columns for 'EmployeeID', 'FirstName', and 'LastName'?
- NEW TABLE Employees (EmployeeID, FirstName, LastName);
- ADD TABLE Employees (EmployeeID, FirstName, LastName);
- CREATE TABLE Employees (EmployeeID, FirstName, LastName); (correct)
- INSERT TABLE Employees (EmployeeID, FirstName, LastName);
What is the SQL command to remove a database named 'CompanyDB'?
What is the SQL command to remove a database named 'CompanyDB'?
Which of the following accurately describes the fundamental structure of a SQL table?
Which of the following accurately describes the fundamental structure of a SQL table?
In SQL, what is the function of the SET clause within an UPDATE statement?
In SQL, what is the function of the SET clause within an UPDATE statement?
What action does the SQL command DROP TABLE
perform?
What action does the SQL command DROP TABLE
perform?
In an SQL INSERT INTO
statement, which keyword immediately precedes the list of column names?
In an SQL INSERT INTO
statement, which keyword immediately precedes the list of column names?
What is the primary purpose of a PRIMARY KEY in a database table?
What is the primary purpose of a PRIMARY KEY in a database table?
What accurately describes a FOREIGN KEY in the context of relational databases?
What accurately describes a FOREIGN KEY in the context of relational databases?
Which SQL statement would you use to retrieve all columns and all rows from a table named 'Products'?
Which SQL statement would you use to retrieve all columns and all rows from a table named 'Products'?
Which SQL clause enables the filtering of records based on a specific condition?
Which SQL clause enables the filtering of records based on a specific condition?
What SQL statement would correctly update the 'Salary' to 65000 for an employee with 'EmployeeID' equal to 2 in a table named 'Employees'?
What SQL statement would correctly update the 'Salary' to 65000 for an employee with 'EmployeeID' equal to 2 in a table named 'Employees'?
Which SQL statement is used to create a new table that inherits the structure and data from an existing table?
Which SQL statement is used to create a new table that inherits the structure and data from an existing table?
In SQL, what is the function of a WHERE
clause?
In SQL, what is the function of a WHERE
clause?
Which data type is NOT a valid option in SQL?
Which data type is NOT a valid option in SQL?
What is the primary function of setting a column as AUTO_INCREMENT
when defining it as a primary key?
What is the primary function of setting a column as AUTO_INCREMENT
when defining it as a primary key?
In an Entity-Relationship Diagram (ERD), what does a rectangle typically represent?
In an Entity-Relationship Diagram (ERD), what does a rectangle typically represent?
In an Entity-Relationship Diagram (ERD), what shape represents attributes?
In an Entity-Relationship Diagram (ERD), what shape represents attributes?
What concept does cardinality indicate in an ERD?
What concept does cardinality indicate in an ERD?
Flashcards
What does SELECT do?
What does SELECT do?
Extracts data from a database.
What does DROP TABLE do?
What does DROP TABLE do?
It deletes a table.
What a PRIMARY KEY is used for?
What a PRIMARY KEY is used for?
Uniquely identify each row in a table.
What is a foreign key?
What is a foreign key?
Signup and view all the flashcards
Purpose of WHERE Clause
Purpose of WHERE Clause
Signup and view all the flashcards
VARCHAR stands for what?
VARCHAR stands for what?
Signup and view all the flashcards
What is data redundancy?
What is data redundancy?
Signup and view all the flashcards
What does 1NF ensure?
What does 1NF ensure?
Signup and view all the flashcards
What is a composite primary key?
What is a composite primary key?
Signup and view all the flashcards
What is a partial dependency?
What is a partial dependency?
Signup and view all the flashcards
What does 2NF address?
What does 2NF address?
Signup and view all the flashcards
What is a transitive dependency?
What is a transitive dependency?
Signup and view all the flashcards
Which normal form is 3NF?
Which normal form is 3NF?
Signup and view all the flashcards
One-to-many relationships
One-to-many relationships
Signup and view all the flashcards
Symbol for Entity in ERD
Symbol for Entity in ERD
Signup and view all the flashcards
Type of Relationship
Type of Relationship
Signup and view all the flashcards
Composite key
Composite key
Signup and view all the flashcards
What Normalization does?
What Normalization does?
Signup and view all the flashcards
Anomaly causes?
Anomaly causes?
Signup and view all the flashcards
Common Issue in UNF Table:
Common Issue in UNF Table:
Signup and view all the flashcards
Study Notes
SQL Commands
- SELECT extracts data from a database.
- DELETE FROM table_name WHERE condition removes data from a table.
- CREATE TABLE table_name is used to make a new table.
- DROP DATABASE database_name deletes a database.
- UPDATE is a SQL command used to extract data.
- DROP TABLE removes a table.
- The VALUES keyword follows column names in the INSERT INTO syntax.
- The WHERE clause filters records based on a specified condition.
- UPDATE Employees SET Salary = 65000 WHERE EmployeeID = 2; will update an employee's salary.
- CREATE TABLE AS is an SQL statement that makes a new table based on an existing one.
- The WHERE clause specifies conditions for data retrieval or modification.
Data Types
- INT is a valid data type in SQL.
- VARCHAR is a valid data type in SQL.
- BOOLEAN is a valid data type in SQL.
- IMAGE is not a valid data type in SQL.
- VARCHAR stands for Variable-length Character.
- FLOAT stores floating-point numbers.
Primary and Foreign Keys
- A PRIMARY KEY uniquely identifies each row in a table.
- Setting a column as AUTO_INCREMENT automatically generates a unique numeric value for each new row, when defining a primary key.
- A foreign key references the primary key of another table.
- If a table is created from another table using "CREATE TABLE AS SELECT * FROM...", the primary key constraint is not copied and must be defined manually.
- A composite primary key consists of two or more columns.
ERD
- A rectangle represents an entity in an ERD
- An Oval/Ellipse represents attributes in a ERD
- A Diamond represents relationships in an ERD.
- Indexes are not a component of an ERD.
- Relationships represents the connections between entities in ERDs
- Cardinality indicates the number of occurrences of an entity in a relationship within an ERD.
Normal Forms & Dependencies
- Second Normal Form ensures all non-key attributes are fully dependent on the primary key.
- The primary goal of normalization is to minimize data redundancy and dependency.
- Anomalies in databases is an error resulting from data redundancy.
- First Normal Form (1NF) ensures each column contains only individual values.
- "Atomic value" refers to an attribute that cannot be further subdivided.
- Third Normal Form (3NF) eliminates transitive dependency.
- In the context of normalization, a partial dependency occurs when a non-key attribute depends on only part of a composite primary key.
- Transitive dependency happens when a non-key attribute depends on another non-key attribute.
Relationships
- A customer and their orders is an example of a one-to-many relationship.
- In a one-to-one relationship, one entity is related to only one other entity, and vice versa.
- The example "A student can enroll in multiple courses, and each course can have multiple students" represents a many-to-many relationship.
Additional
- Data redundancy means storing the same data in multiple locations.
- More than one value in cells is a common issue with cells in UNF tables.
- Poor maintenance causes anomalies in a database.
- Anomalies are typically categorized into three main types.
- Combining columns on a Composite Primary key ensures uniqueness.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.