Graph Databases (Neo4j, Amazon Neptune) Flashcards

Model and query complex relationships using graph theory. "What is a graph database and where would you use it?" "How is Cypher query language different from SQL?" Topics: Nodes, relationships, properties Use cases: social networks, fraud detection, recommendation systems Neo4j and the Cypher query language Querying patterns and traversals Indexes and constraints in Neo4j Amazon Neptune overview Graph algorithms: shortest path, PageRank, centrality (30 cards)

1
Q

What is a graph database and where would you use it?

A

A graph database stores data as nodes and relationships, making it ideal for use cases involving highly connected data like social networks, fraud detection, and recommendations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are nodes in a graph database?

A

Nodes represent entities such as people, products, or places in a graph database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are relationships in a graph database?

A

Relationships are directed connections between nodes, representing how entities are related.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are properties in a graph database?

A

Properties are key-value pairs stored on nodes and relationships to hold additional metadata.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How is Cypher query language different from SQL?

A

Cypher uses pattern matching to traverse graphs, unlike SQL which uses JOINs to relate tables in relational databases.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is Cypher used for in Neo4j?

A

Cypher is the query language for Neo4j, used to match patterns, create or delete nodes and relationships, and return query results.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are some common use cases for graph databases?

A

Social networks, fraud detection, recommendation engines, network and IT operations, and knowledge graphs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is pattern matching in graph databases?

A

Pattern matching refers to specifying a sequence of nodes and relationships in a query to extract relevant subgraphs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a graph traversal?

A

Graph traversal is the process of visiting connected nodes in a graph, often used in queries and algorithms like shortest path.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is an index in Neo4j?

A

An index in Neo4j speeds up lookups of nodes or relationships by property values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are constraints in Neo4j?

A

Constraints enforce rules like uniqueness of a property (e.g., a user ID) on nodes or relationships to maintain data integrity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Amazon Neptune?

A

Amazon Neptune is a fully managed graph database service that supports both property graphs (via Gremlin) and RDF data (via SPARQL).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the main query languages supported by Amazon Neptune?

A

Neptune supports Gremlin for property graph model and SPARQL for RDF graph model.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the shortest path algorithm in graph databases?

A

It finds the minimum distance between two nodes, commonly used in routing and recommendation systems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is PageRank in graph databases?

A

PageRank is an algorithm that ranks nodes based on the number and quality of their incoming links, useful in web search and influence analysis.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is centrality in graph analysis?

A

Centrality measures how important a node is within a graph based on its position and connectivity (e.g., degree, closeness, betweenness).

17
Q

What are advantages of graph databases?

A

Efficient for modeling and querying connected data, flexible schema, real-time traversals, and intuitive relationship representation.

18
Q

What are disadvantages of graph databases?

A

They may not scale as well for high write throughput, can be complex to set up and operate, and have limited tooling compared to SQL databases.

19
Q

What are best practices for graph data modeling?

A

Model based on access patterns, avoid deeply nested relationships, use constraints and indexes for performance, and keep relationships meaningful.

20
Q

What are best practices for querying in Neo4j?

A

Use indexes where applicable, avoid Cartesian products, use EXPLAIN/PROFILE to optimize queries, and limit traversal depth.

21
Q

What is the impact of graph databases on system design?

A

They enable more natural modeling of connected domains, reduce JOIN overhead, and are ideal for real-time relationship querying.

22
Q

What is a real-world example of using a graph database?

A

A social media platform using a graph to model users, their connections, posts, and reactions for friend suggestions and feed ranking.

23
Q

What are architectural implications of using graph databases?

A

Applications must be designed to take advantage of graph traversals; data ingestion and consistency models may differ from RDBMS.

24
Q

How do graph databases perform under load?

A

Read queries involving deep relationships are very efficient, but high-volume write loads may require tuning and careful design.

25
How do graph databases ensure fault tolerance?
Managed services like Neo4j Enterprise and Amazon Neptune offer replication, backup, and failover to ensure high availability.
26
How can you monitor a graph database?
Use tools like Neo4j's monitoring dashboard, Amazon CloudWatch for Neptune, and query profiling tools to track query performance and system metrics.
27
How can you debug performance issues in graph queries?
Use `PROFILE` in Cypher or query plans in Gremlin to analyze slow parts, and review use of indexes and graph structure.
28
What are real-world tradeoffs of graph databases?
They offer high performance for connected data but require a new query paradigm and careful design to avoid performance issues with large or complex graphs.
29
What are common graph database interview questions?
Examples: 'What is a graph traversal?', 'How is Cypher different from SQL?', 'What is PageRank?', 'When would you use a graph DB over relational?'
30
What are potential gotchas in graph database usage?
Unindexed property lookups, overly dense nodes (supernodes), and unbounded traversals can lead to poor performance.