Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinku10 committed Sep 11, 2024
1 parent 6fbad7a commit 495b037
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A `Schema` defines a vertex. It can be compared with `struct` in other programmi

This is how a schema named `Person` can be defined.

```
```sql
Schema Person {
name string
age int
Expand All @@ -27,7 +27,7 @@ The names can be unicode letters. Each attribute has to be defined in a newline

A `Vertex` is initialized from a `Schema`. It can be thought of as an `object` or `instance` of a `class` in other programming languages.

```
```sql
Vertex Jintu Person {
.name = "Jintu"
.age = 20
Expand All @@ -42,7 +42,7 @@ An `Edge` is a link between two `Vertex`s. It does not have its own properties (

An `Edge` can be created from one of the predefined base edge. The base edges is like a schema but does not hold any attributes.

```
```sql
Edge LivesIn OneWay
```

Expand All @@ -56,7 +56,7 @@ A relation binds two `Vertex`s with an `Edge`. If the edge type is `OneWay`, the

Assuming `India` exist as a `Vertex`, you can write this:

```
```sql
Relation LivesIn {
Jintu India
}
Expand All @@ -68,7 +68,7 @@ The combination of these entities gives you super-power to write complex graph q

## Find all `Person` who have a one degree friend

```
```sql
Query Person {
[]FriendsWith Person
}
Expand All @@ -78,7 +78,7 @@ Query Person {

A `Vertex` can be aliased for referencing later. This allows defining recursive relations.

```
```sql
Query Person as A {
.name = 'John'
and []FriendsWith Person {
Expand All @@ -91,9 +91,9 @@ Query Person as A {

`()` nodes matches with any vertex and `[]()` matches with any edge.

```
```sql
Query Person as A {
and Sum([]FriendsWith Person {
Sum([]FriendsWith Person {
[]() ()
}, .salary) < .salary
}
Expand All @@ -105,22 +105,22 @@ You can be explicit about it with `A.salary` though.

## Try to figure out the query below

```p
```sql
Query Sum(Person as A {
.name = "Hi"
or (StartsWith(.name, 'H') and .age > 10)
and [1..2]LivesIn () {
[..]Within Country {
.name="India"
and []Within Continent
}
.name = "Hi"
or (StartsWith(.name, 'H') and .age > 10)
and [1..2]LivesIn () {
[..]Within Country {
.name="India"
and []Within Continent
}
}
and Sum([]FriendsWith Person {
[]LivesIn () {
[]Within Country{.name="USA"}
}
and Sum([]FriendsWith Person {
[]LivesIn () {
[]Within Country{.name="USA"}
}
}, .salary) < .salary
}, .age)
}, .salary) < .salary
}, .age)
```

The `[..]` syntax states that the edge can be there any number of times, including zero. The default `[]` evaluates to `[1]` to make the edge appear strictly once.

0 comments on commit 495b037

Please sign in to comment.