Posts

Showing posts with the label database

SQL Window Functions and Ranking

SQL window functions and ranking are powerful tools for performing calculations across sets of rows that relate to the current row. Let me break this down into digestible concepts with practical examples. What are Window Functions? Window functions perform calculations across a set of table rows related to the current row, but unlike aggregate functions, they don't collapse rows into a single result. They "look through a window" at related rows while preserving the original row structure. Basic Syntax: function_name() OVER ( [PARTITION BY column1, column2, ...] [ORDER BY column1, column2, ...] [ROWS/RANGE specification] ) Key Components PARTITION BY : Divides the result set into partitions (like GROUP BY, but doesn't collapse rows) ORDER BY : Defines the order within each partition Window Frame : Specifies which rows to include in the calculation (ROWS/RANGE) Ranking Functions 1. ROW_NUMBER() Assigns a unique sequential integer to each row within a partiti...

Graph Database vs Vector Database

Let's compare Graph and Vector databases. We use both for AI and GenAI applications. It is important to know about their differences to utilise them as per the requirements of the project. 1. Graph Databases (e.g., Neo4j): Core Functionality: Graph databases are designed to store and query data that is heavily interconnected.   They focus on relationships between data points (nodes) rather than just the data itself. They use graph structures with nodes (entities) and edges (relationships) to represent and store data. They excel at traversing and analyzing complex relationships, finding patterns, and performing network analysis. They use query languages like Cypher (in Neo4j) that are optimized for graph traversals. Key Characteristics: Emphasis on relationships and connections. Optimized for complex queries involving multiple levels of relationships. Efficient for finding patterns and dependencies. Not designed for similarity searches based on vector embeddings. Us...