Quiz: Graph Query Languages and Technologies
Test your understanding of graph query languages with these questions.
1. What is Cypher?
- A relational database management system
- A declarative graph query language designed for pattern matching
- A programming language for web development
- A type of encryption algorithm
Show Answer
The correct answer is B. Cypher is a declarative graph query language originally developed for Neo4j, designed specifically for pattern matching in graph databases. It uses ASCII-art syntax to describe patterns of nodes and relationships, making queries intuitive and readable. Option A describes RDBMSs. Options C and D are unrelated technologies.
Concept Tested: Cypher Query Language
2. What is the primary purpose of graph pattern matching?
- To encrypt healthcare data
- To delete all nodes in a database
- To convert graphs to tables
- To find subgraphs that match specified node and relationship patterns
Show Answer
The correct answer is D. Graph pattern matching is the process of finding all subgraphs within a graph database that match a specified pattern of nodes, relationships, and properties. This is the fundamental operation underlying most graph queries, enabling questions like "find all patients treated by Dr. Smith" or "what medications are prescribed for diabetes?"
Concept Tested: Graph Pattern Matching
3. Which of the following Cypher queries would find all patients who have a specific diagnosis?
SELECT * FROM patients WHERE diagnosis='Diabetes'MATCH (p:Patient)-[:HAS_DIAGNOSIS]->(d:Diagnosis {name:'Diabetes'}) RETURN pDELETE (p:Patient) WHERE p.diagnosis='Diabetes'CREATE TABLE patients WITH diagnosis
Show Answer
The correct answer is B. The MATCH clause in Cypher uses pattern matching to find Patient nodes connected to Diagnosis nodes via HAS_DIAGNOSIS relationships where the diagnosis name is 'Diabetes'. Option A is SQL syntax. Option C would delete data. Option D is DDL for table creation.
Concept Tested: Cypher Query Language, Graph Pattern Matching
4. What is a graph index used for?
- To slow down query performance intentionally
- To delete duplicate data
- To encrypt sensitive information
- To speed up lookups of nodes or edges by specific properties
Show Answer
The correct answer is D. Graph indexes accelerate query performance by creating efficient lookup structures for specific node or edge properties. For example, indexing patient IDs enables fast retrieval of specific patient records without scanning all nodes. Option A is the opposite of the purpose. Options B and C describe different functionalities.
Concept Tested: Graph Index
See: Graph Indexes
5. What is GQL?
- Graph Query Language, an international standard for querying property graphs
- A proprietary database product
- A machine learning algorithm
- A healthcare coding system
Show Answer
The correct answer is A. GQL (Graph Query Language) is an international standard (ISO/IEC 39075) for querying property graphs, developed to provide vendor-neutral syntax similar to how SQL standardizes relational queries. It aims to improve portability across different graph database systems. Options B, C, and D are incorrect.
Concept Tested: GQL Standard
See: GQL Standard
6. Given a query that needs to find all patients within 3 hops of a specific provider, what type of query is this?
- Aggregate query
- Delete query
- Path query
- Schema query
Show Answer
The correct answer is C. A path query traverses relationships across multiple hops to find nodes at specific distances or along particular paths. Finding "all patients within 3 hops" requires traversing up to 3 edges from the provider node. Option A computes statistics. Options B and D are unrelated.
Concept Tested: Path Query
See: Path Queries
7. How does query optimization improve graph query performance?
- By making queries run slower
- By deleting all indexes
- By reordering operations, using indexes, and pushing down filters to minimize intermediate results
- By converting all data to CSV files
Show Answer
The correct answer is C. Graph query optimization involves techniques like reordering traversal operations, utilizing indexes to start from selective nodes, pushing filters down to reduce intermediate result sets, and choosing efficient join strategies. These optimizations can dramatically improve query performance on large graphs. Options A, B, and D would harm performance.
Concept Tested: Graph Query Optimization
See: Query Optimization
8. What is an aggregate query in a graph database?
- A query that deletes nodes
- A query that creates new relationships
- A query that computes summary statistics like COUNT, AVG, or SUM across nodes or edges
- A query that renames properties
Show Answer
The correct answer is C. Aggregate queries compute summary statistics across multiple graph elements, such as counting the number of patients per provider, calculating average medication costs, or summing total claims amounts. These use aggregate functions like COUNT(), AVG(), SUM(), MIN(), and MAX(). Options A, B, and D describe different operations.
Concept Tested: Aggregate Query
See: Aggregate Queries
9. Which query language is specifically designed for TigerGraph?
- Cypher
- SQL
- GQL
- GSQL
Show Answer
The correct answer is D. GSQL is the graph query language developed specifically for TigerGraph database. It combines graph pattern matching with procedural logic and is designed for high-performance analytics on large-scale graphs. Cypher (A) is for Neo4j, SQL (B) is for relational databases, and GQL (C) is a cross-platform standard.
Concept Tested: GSQL
See: GSQL
10. Analyze this scenario: A hospital query takes 30 seconds to find all patients connected to a specific provider through any path. After adding an index on provider IDs and restructuring the query to start from the provider node, it now takes 2 seconds. What optimization principle was applied?
- The query was made slower intentionally
- Selective starting points and indexing reduced the search space
- All data was deleted
- The database was converted to a relational model
Show Answer
The correct answer is B. The optimization applied two key principles: (1) indexing provider IDs enables fast lookup of the starting node, and (2) starting traversal from the selective provider node (fewer providers than patients) reduces the search space compared to scanning all patients. These are fundamental graph query optimization techniques. Options A, C, and D don't describe the actual improvement.
Concept Tested: Graph Query Optimization, Graph Index, Query Performance
See: Query Optimization