Download Database Design and SQL Fundamentals Quiz and more Exams Computer Science in PDF only on Docsity!
Database Design and Normalization:
Principles and Practices
- What does a table in a database represent? o โ A collection of rows and columns o A single data entry o A list of commands o A programming language
- In a table, what is a row called? o โ A record o A column o A key o A field
- What is a column in a database table? o โ A set of data values of a particular type o A single data entry o A list of rows o A relation
- Which SQL command is used to retrieve data? o โ SELECT o INSERT o UPDATE o DELETE
- Which SQL command adds new data to a table? o SELECT o โ INSERT o UPDATE o DELETE
- Which SQL command changes existing data in a table? o SELECT o INSERT o โ UPDATE o DELETE
- Which SQL command removes data from a table? o SELECT o INSERT o UPDATE o โ DELETE
- What uniquely identifies a record in a database table? o A foreign key o โ A primary key o A column name o An index
- What links two tables in a relational database?
- What is the difference between a primary key and a foreign key? o Both are the same o Primary key identifies rows, foreign key relates tables โ o Primary key relates tables, foreign key identifies rows o Neither has a specific function
- Which command updates the age of employee โJohnโ to 31? o UPDATE Employees SET Age = 31 WHERE Name = 'John'; โ o INSERT INTO Employees (Age) VALUES (31) WHERE Name = 'John'; o SELECT Age = 31 FROM Employees WHERE Name = 'John'; o DELETE Age FROM Employees WHERE Name = 'John';
- How do you delete all records from a table named "Orders"? o DELETE * Orders; o โ DELETE FROM Orders; o REMOVE FROM Orders; o DELETE Records FROM Orders;
- What does the term โdata modelโ refer to in databases?
o A programming language o A software interface o โ A way to organize data into tables, rows, and columns o A type of database engine
- Which of the following best describes a "row"? o A column header o โ A single entry in a table o A database itself o A key column
- An attribute in a database corresponds to which element? o Row o โ Column o Table o Record
- Which SQL command would you use to add a new column to an existing table? o INSERT COLUMN o UPDATE COLUMN o โ ALTER TABLE o SELECT COLUMN
- When writing an SQL SELECT query, which clause filters the records?
o โ Must reference a primary key in another table o Always a number o Must be a text field
- Which command is used to change data in an existing row? o โ UPDATE o INSERT o DELETE o MODIFY
- How do you retrieve only the "Name" column from a table named "Users"? o SELECT USERS.Name; o SELECT COLUMN Name FROM Users; o โ SELECT Name FROM Users; o GET Name FROM Users;
- Consider two tables: Orders (OrderID, CustomerID) and Customers (CustomerID, Name). What is CustomerID in Orders? o Primary key o โ Foreign key o Unique key o Index
- What is the purpose of the WHERE clause in SQL?
o To select tables o To join tables o โ To filter records based on a condition o To order results
- In SQL, which command would add a new row to a table? o UPDATE o DELETE o SELECT o โ INSERT
- What is a composite key? o A single primary key o A foreign key o โ A primary key made up of multiple columns o A key used only for sorting
- Which SQL statement would update the salary of employees in department 5? o UPDATE Employees SET Salary=5000; o โ UPDATE Employees SET Salary=5000 WHERE DepartmentID=5; o INSERT Salary=5000 WHERE DepartmentID=5; o DELETE Salary FROM Employees WHERE DepartmentID=5;
- How do you remove a column from a table?
o A property of stored procedures o โ Ensures foreign keys correctly reference primary keys o The speed of query execution o The uniqueness of primary keys
- Can a table have more than one foreign key? o No o โ Yes o Only if it has no primary key o Only in NoSQL databases
- What result does the following SQL produce? SELECT Name FROM Employees WHERE Age > 30; o โ Returns names of employees older than 30 o Returns all names o Returns ages of employees o Throws an error
- In a SQL database, what is a โrecordโ? o A column in a table o โ A row of data in a table o A type of data model o An SQL command
- What is the function of the PRIMARY KEY constraint? o Allows duplicate values
o โ Uniquely identifies each row in a table o References other tables o Sorts data
- Which statement correctly deletes a record with ID=10 from a table called Products? o DELETE Products WHERE ID=10; o DELETE * FROM Products WHERE ID=10; o โ DELETE FROM Products WHERE ID=10; o REMOVE FROM Products WHERE ID=10;
- What does the SQL INSERT INTO statement do? o Deletes data o โ Adds new data to a table o Retrieves data o Updates data
- What is the keyword to change existing data? o INSERT o DELETE o โ UPDATE o SELECT
- Which of the following describes a foreign key? o A key unique to the table o โ A field that points to a primary key in another table
o ORDER BY o GROUP BY o HAVING
- A primary key must have which of the following characteristics? o Allows duplicates o Can be NULL o โ Unique and not NULL o Optional in tables
- Why use foreign keys? o To speed up queries o To sort data o โ To maintain relationships between tables o To duplicate data