Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Feedback Collection and Annotation
📖 Scenario: You are building a simple feedback system for a website. Users submit feedback messages, and you want to store these messages along with a label that describes the sentiment of the feedback (positive, neutral, or negative).This system will help the website team quickly understand user opinions and improve the site.
🎯 Goal: Create a small database structure to store user feedback messages and their sentiment labels. Then, write code to add new feedback entries and annotate each with a sentiment label.
📋 What You'll Learn
Create a dictionary called feedback_db to store feedback messages as keys and their sentiment labels as values.
Create a variable called new_feedback with the exact string: 'The website is very easy to use'.
Add a new entry to feedback_db using new_feedback as the key and 'positive' as the value.
Add a final entry to feedback_db with the key 'The site is slow' and the value 'negative'.
💡 Why This Matters
🌍 Real World
Collecting and labeling user feedback helps businesses understand customer satisfaction and improve their products or services.
💼 Career
Database skills for storing and managing user-generated content are essential for roles in data analysis, product management, and software development.
Progress0 / 4 steps
1
Create the initial feedback database
Create a dictionary called feedback_db with these exact entries: 'Great service': 'positive', 'Could be better': 'neutral', and 'Not satisfied': 'negative'.
LangChain
Hint
Use curly braces {} to create a dictionary. Each entry should have the feedback message as the key and the sentiment label as the value.
2
Add a new feedback message variable
Create a variable called new_feedback and assign it the string 'The website is very easy to use'.
LangChain
Hint
Use the assignment operator = to assign the string to the variable.
3
Add the new feedback to the database
Add a new entry to feedback_db using new_feedback as the key and 'positive' as the value.
LangChain
Hint
Use square brackets [] to add a new key-value pair to the dictionary.
4
Add a final feedback entry
Add a new entry to feedback_db with the key 'The site is slow' and the value 'negative'.
LangChain
Hint
Use the dictionary key assignment syntax to add the new entry.
Practice
(1/5)
1. What is the main purpose of feedback collection in a database?
easy
A. To speed up database queries
B. To delete old user data automatically
C. To store user opinions for later review
D. To create user accounts
Solution
Step 1: Understand feedback collection
Feedback collection means saving what users say or think about something.
Step 2: Identify the purpose in database context
In databases, feedback is stored so it can be reviewed or analyzed later.
Final Answer:
To store user opinions for later review -> Option C
Quick Check:
Feedback collection = store opinions [OK]
Hint: Feedback stores user opinions, not deletes or speeds queries [OK]
Common Mistakes:
Confusing feedback with user account data
Thinking feedback speeds up queries
Assuming feedback deletes old data
2. Which SQL command correctly creates a table named feedback with columns id (integer) and comment (text)?
easy
A. CREATE feedback TABLE (id INT, comment TEXT);
B. CREATE TABLE feedback (id INT, comment TEXT);
C. MAKE TABLE feedback (id INTEGER, comment STRING);
D. TABLE CREATE feedback (id INT, comment TEXT);
Solution
Step 1: Recall correct SQL syntax for table creation
The correct syntax starts with CREATE TABLE, followed by table name and columns with types.
Step 2: Check each option for syntax correctness
CREATE TABLE feedback (id INT, comment TEXT); uses correct keywords and types. Others have wrong keywords or order.
Final Answer:
CREATE TABLE feedback (id INT, comment TEXT); -> Option B
Hint: CREATE TABLE is the right start for making tables [OK]
Common Mistakes:
Using MAKE TABLE instead of CREATE TABLE
Wrong order of keywords
Using STRING instead of TEXT for text columns
3. Given the table feedback with columns id and comment, what will this query return?
SELECT comment FROM feedback WHERE id = 2;
medium
A. Only the comment text where id equals 2
B. An error because id is not selected
C. All ids and comments
D. All comments with id 2
Solution
Step 1: Understand the SELECT statement
The query asks for the comment column only, filtering rows where id equals 2.
Step 2: Determine what is returned
Only the comment text for the row with id 2 is returned, not all comments or ids.
Final Answer:
Only the comment text where id equals 2 -> Option A
Quick Check:
SELECT comment WHERE id=2 = Only the comment text where id equals 2 [OK]
Hint: SELECT column filters output columns, WHERE filters rows [OK]
Common Mistakes:
Thinking all comments with id 2 means multiple rows
Expecting id column in output when not selected
Assuming syntax error due to missing id in SELECT
4. Identify the error in this SQL statement for inserting feedback:
INSERT INTO feedback (id, comment) VALUES 1, 'Great service';
medium
A. Missing parentheses around VALUES
B. Wrong table name
C. Missing semicolon
D. Using single quotes instead of double quotes
Solution
Step 1: Review correct INSERT syntax
VALUES must be followed by parentheses enclosing the values to insert.
Step 2: Check the given statement
The statement lacks parentheses around 1, 'Great service' after VALUES.
Final Answer:
Missing parentheses around VALUES -> Option A
Quick Check:
VALUES requires parentheses [OK]
Hint: Always put parentheses around VALUES in INSERT [OK]
Common Mistakes:
Forgetting parentheses after VALUES
Confusing quotes for strings
Assuming semicolon is mandatory for error
5. You want to label feedback comments as 'positive' or 'negative' in a new column annotation. Which SQL command correctly adds this column to the feedback table?
hard
A. INSERT COLUMN annotation INTO feedback;
B. UPDATE feedback ADD annotation TEXT;
C. CREATE COLUMN annotation TEXT IN feedback;
D. ALTER TABLE feedback ADD COLUMN annotation TEXT;
Solution
Step 1: Understand how to add a new column
To add a column, use ALTER TABLE with ADD COLUMN and specify the type.
Step 2: Check each option's correctness
ALTER TABLE feedback ADD COLUMN annotation TEXT; uses correct syntax. Others use invalid commands or order.
Final Answer:
ALTER TABLE feedback ADD COLUMN annotation TEXT; -> Option D
Quick Check:
ALTER TABLE + ADD COLUMN = ALTER TABLE feedback ADD COLUMN annotation TEXT; [OK]
Hint: Use ALTER TABLE ADD COLUMN to add new columns [OK]