0
0
Prompt Engineering / GenAIml~10 mins

Vector database operations (CRUD) in Prompt Engineering / GenAI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to insert a vector into the database.

Prompt Engineering / GenAI
db.[1](vector_id='vec1', vector=[0.1, 0.2, 0.3])
Drag options to blanks, or click blank then click option'
Aupdate
Bdelete
Cinsert
Dsearch
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'delete' instead of 'insert' will remove data instead of adding.
Using 'update' tries to change existing data, not add new.
Using 'search' is for finding vectors, not adding.
2fill in blank
medium

Complete the code to retrieve a vector by its ID.

Prompt Engineering / GenAI
result = db.[1](vector_id='vec1')
Drag options to blanks, or click blank then click option'
Aget
Bupdate
Cdelete
Dinsert
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'insert' tries to add data instead of retrieving.
Using 'delete' removes data instead of fetching.
Using 'update' modifies data instead of fetching.
3fill in blank
hard

Fix the error in the code to update a vector's values.

Prompt Engineering / GenAI
db.[1](vector_id='vec1', vector=[0.4, 0.5, 0.6])
Drag options to blanks, or click blank then click option'
Ainsert
Bupdate
Cget
Dsearch
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'insert' will add a new vector instead of updating.
Using 'get' only retrieves data, does not change it.
Using 'search' finds vectors but does not update.
4fill in blank
hard

Fill both blanks to delete a vector and confirm its removal.

Prompt Engineering / GenAI
db.[1](vector_id='vec2')
exists = db.[2](vector_id='vec2')
Drag options to blanks, or click blank then click option'
Adelete
Binsert
Cget
Dupdate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'insert' instead of 'delete' will add data instead of removing.
Using 'update' does not remove data.
Using 'insert' or 'update' to check existence is incorrect.
5fill in blank
hard

Fill all three blanks to perform a search, update a vector, and then retrieve it.

Prompt Engineering / GenAI
results = db.[1](query_vector=[0.1, 0.2, 0.3], top_k=5)
db.[2](vector_id='vec3', vector=[0.7, 0.8, 0.9])
updated_vector = db.[3](vector_id='vec3')
Drag options to blanks, or click blank then click option'
Ainsert
Bupdate
Cget
Dsearch
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'insert' instead of 'search' will add data instead of finding.
Using 'get' instead of 'update' will not change the vector.
Using 'delete' in any step will remove data unexpectedly.