This page provides documentation for the SographDB framework. SographDB is a powerful graph database that allows you to store and query graph-structured data efficiently. This documentation will guide you through the installation process, functionality overview, and usage of SographDB.
Installation
To get started with SographDB, you need to follow these steps:
- Download the SographDB framework from the official website or GitHub repository.
- Extract the downloaded file to your desired location.
- Open your project in Xcode.
- Drag and drop the SographDB framework into your project.
- In Xcode, select your project’s target and go to the “General” tab.
- Add SographDB framework under the “Embedded Binaries” section.
- You are now ready to use SographDB in your project.
Getting Started
Now that you have successfully installed SographDB, follow these steps to start using it:
- Create a new instance of the SographDB object.
- Connect to a SographDB server using the provided credentials.
- Create a new graph and define its schema.
- Start adding vertices and edges to the graph.
- Perform various queries and traversals on the graph.
// Instantiate SographDB
let sographDB = SographDB()
// Connect to SographDB server
sographDB.connect(host: "your_host", port: 12345, username: "your_username", password: "your_password")
// Create graph and define schema
let graph = sographDB.createGraph(name: "your_graph_name")
graph.defineVertex("Person", properties: ["name", "age"])
graph.defineEdge("Friendship", properties: ["date"])
// Add vertices and edges to graph
let personVertex = graph.addVertex(label: "Person", properties: ["name": "John Doe", "age": 25])
let friendVertex = graph.addVertex(label: "Person", properties: ["name": "Jane Smith", "age": 30])
let friendshipEdge = graph.addEdge(label: "Friendship", from: personVertex, to: friendVertex, properties: ["date": "2021-01-01"])
// Perform queries and traversals
let result = graph.queryVertices(label: "Person", properties: ["name": "John Doe"])
let traversal = graph.traverse(from: personVertex, through: "Friendship", direction: .out)
Features
SographDB offers the following key features:
- Schema Definition: Define the schema for your graph and its entities.
- Vertex and Edge Creation: Add vertices and edges to the graph with specified properties.
- Querying and Traversing: Perform queries and traversals on the graph.
- Indexing: Optimize query performance by creating indexes on graph properties.
- Transactions: Support for ACID transactions to ensure data integrity.
- Backup and Restore: Create backups of your graph database and restore data if needed.
Usage Examples
Here are a few examples of how you can utilize SographDB:
Example 1: Creating a Graph
To create a graph named “SocialNetwork” with two vertex labels (“Person” and “Interest”) and an edge label (“Follows”), use the following code:
// Create graph and define schema
let graph = sographDB.createGraph(name: "SocialNetwork")
graph.defineVertex("Person", properties: ["name", "age"])
graph.defineVertex("Interest", properties: ["name"])
graph.defineEdge("Follows")
Example 2: Adding Vertices and Edges
Now, let’s add a few vertices and edges to the graph:
// Add vertices and edges to graph
let personVertex = graph.addVertex(label: "Person", properties: ["name": "John Doe", "age": 25])
let interestVertex = graph.addVertex(label: "Interest", properties: ["name": "Hiking"])
let followsEdge = graph.addEdge(label: "Follows", from: personVertex, to: interestVertex)
Example 3: Querying the Graph
To query all vertices of the “Person” label, you can use the following code:
// Query vertices
let result = graph.queryVertices(label: "Person")
Conclusion
Congratulations! You have successfully learned how to install, use, and explore the features of SographDB. Start building efficient graph-structured databases with ease using SographDB!