Relational Algebra Engine
Loading...
Searching...
No Matches
Classes | Functions
relation.c File Reference

Relation implementation for the Relational Algebra Engine. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "relation.h"
Include dependency graph for relation.c:

Classes

struct  FindTupleContext
 

Functions

Relation * relation_create (const char *name)
 Create a new Relation.
 
void relation_destroy (Relation *r)
 Destroy a Relation and free its memory.
 
int relation_add_tuple (Relation *r, Tuple *t)
 Add a tuple to a relation.
 
void relation_print (const Relation *r)
 Print a Relation to stdout.
 
Tuple * relation_find_tuple (Relation *r, Tuple *target)
 Find a tuple in a relation matching the target.
 

Detailed Description

Relation implementation for the Relational Algebra Engine.

Provides creation, destruction, and manipulation of relations (for now, simply sets of tuples), adhering to the strict theoretical model of relational algebra.

Function Documentation

◆ relation_add_tuple()

int relation_add_tuple ( Relation *  r,
Tuple *  t 
)

Add a tuple to a relation.

Parameters
rPointer to the Relation.
tPointer to the Tuple to add.
Returns
1 if added, 0 if already present, -1 on error.

◆ relation_create()

Relation * relation_create ( const char *  name)

Create a new Relation.

Parameters
nameName of the relation (copied).
Returns
Pointer to the new Relation, or NULL on failure.

◆ relation_destroy()

void relation_destroy ( Relation *  r)

Destroy a Relation and free its memory.

Parameters
rPointer to the Relation to destroy. Safe to pass NULL.

◆ relation_find_tuple()

Tuple * relation_find_tuple ( Relation *  r,
Tuple *  target 
)

Find a tuple in a relation matching the target.

Parameters
rPointer to the Relation.
targetPointer to the Tuple to find.
Returns
Pointer to the found Tuple, or NULL if not found.

◆ relation_print()

void relation_print ( const Relation *  r)

Print a Relation to stdout.

Parameters
rPointer to the Relation to print.