What is a Database Management System (DBMS)?
What is the difference between DDL and DML in SQL?
Write an SQL command to create a table named “Books” with columns for ID, Title, and Price.
How can you use an SQL SELECT query to retrieve data from multiple tables?
What does the DROP TABLE command do, and what is a potential risk of using it?
Answers and Descriptions:
Answer: A DBMS is software that manages databases, handling data storage, retrieval, and security.
Description: Examples like MySQL or Oracle DBMS provide tools to create, query, and maintain databases, ensuring efficient data management and user access control.Answer: DDL (Data Definition Language) defines database structure (e.g., CREATE, ALTER), while DML (Data Manipulation Language) manipulates data (e.g., INSERT, UPDATE).
Description: DDL shapes the database schema, like creating tables, while DML handles data operations, like adding records. This distinction helps students understand SQL’s dual role in database management.Answer:
1 2 3 4 5 6 | CREATE TABLE Books ( ID INT PRIMARY KEY, Title VARCHAR(100) NOT NULL, Price DECIMAL(5,2) ); |
Description: This command creates a “Books” table with an integer ID as the primary key, a non-null title (up to 100 characters), and a price with two decimal places. It demonstrates proper use of data types and constraints.
Answer: Use a SELECT query with an INNER JOIN to combine data from multiple tables based on a common column.
Description: For example, SELECT Students.Name, Grades.Score FROM Students INNER JOIN Grades ON Students.ID = Grades.StudentID retrieves names and scores by linking tables via StudentID. Joins enable complex queries across related data.Answer: The DROP TABLE command deletes a table and all its data. A risk is permanent data loss if not backed up.
Description: For example, DROP TABLE Books; removes the “Books” table entirely. Students must understand the irreversible nature of this command and the importance of backups.
