Basic CRUD Definition
What does the acronym CRUD stand for in database operations?
- Create, Read, Update, Delete
- Create, Run, Undo, Drop
- Check, Remove, Upload, Download
- Copy, Restore, Update, Delete
- Create, Remove, Upload, Download
SQL Insert Syntax
Which SQL statement correctly inserts a new user with name 'Alice' into the table users?
- INSERT INTO users (name) VALUES ('Alice');
- INSERT users (name) VALUE ('Alice');
- NEW users SET name = 'Alice';
- ADD TO users SET name = 'Alice';
- SAVE INTO users (name) 'Alice';
Reading Data
You want to retrieve all records from the 'products' table. Which SQL command should you use?
- SELECT * FROM products;
- GET ALL FROM products;
- RETRIEVE FROM products ALL;
- SELECT ALL IN products;
- FIND * IN products;
Update Operation Example
To change the email of user with id = 3 to 'new@mail.com' in a 'users' table, which SQL statement is correct?
- UPDATE users SET email = 'new@mail.com' WHERE id = 3;
- MODIFY users email TO 'new@mail.com' WHERE id = 3;
- SET users.email = 'new@mail.com' FOR id = 3;
- CHANGE users SET email TO 'new@mail.com' WHEN id = 3;
- ALTER users SET email='new@mail.com' WHERE user_id = 3;
Deleting a Record
Which SQL statement deletes a single record from the 'orders' table where the order_id is 101?
- DELETE FROM orders WHERE order_id = 101;
- REMOVE FROM orders WHERE order_id = 101;
- DEL orders WHERE order_id = 101;
- DESTROY orders WHERE order_id equals 101;
- ERASE FROM orders ORDER_ID = 101;
Foreign Key Integration
Why are foreign keys important in integrating multiple database tables?
- They enforce referential integrity between related tables.
- They speed up data insertion for large tables.
- They encrypt sensitive column values.
- They automatically generate primary keys.
- They duplicate data for backup purposes.
API Integration Scenario
A web application fetches product data from a PostgreSQL database and displays it in real time. Which CRUD operation is primarily being utilized?
- Read
- Create
- Update
- Delete
- Restore
Handling Duplicate Entries
Which SQL keyword prevents the insertion of duplicate values in a column?
- UNIQUE
- PRIMARY
- INDEX
- FIRST
- DISTINCT
Practical CRUD in Code
Consider the following Python code using SQLAlchemy:nnsession.query(User).filter_by(id=5).delete()nnWhich CRUD operation does this line perform?
- Delete
- Create
- Read
- Update
- Drop
Common Mistake in CRUD APIs
In RESTful API design, which HTTP method should be used to update a resource fully?
- PUT
- GET
- POST
- DELETE
- FETCH