Category: arangodb

  • Khóa học miễn phí Crud Operations Using Web Interface nhận dự án làm có lương

    Crud Operations using Web Interface



    In our previous chapter, we learned how to perform various operations on documents with Arangosh, the command line. We will now learn how to perform the same operations using the web interface. To start with, put the following address – http://your_server_ip:8529/_db/song_collection/_admin/aardvark/index.html#login in the address bar of your browser. You will be directed to the following login page.

    Login Page

    Now, enter the username and password.

    Login Username Password

    If it is successful, the following screen appears. We need to make a choice for the database to work on, the _system database being the default one. Let us choose the song_collection database, and click on the green tab −

    Song Collection

    Creating a Collection

    In this section, we will learn how to create a collection. Press the Collections tab in the navigation bar at the top.

    Our command line added songs collection are visible. Clicking on that will show the entries. We will now add an artists’ collection using the web interface. Collection songs which we created with Arangosh is already there. In the Name field, write artists in the New Collection dialog box that appears. Advanced options can safely be ignored and the default collection type, i.e. Document, is fine.

    Creating Collection

    Clicking on the Save button will finally create the collection, and now the two collections will be visible on this page.

    Filling Up the Newly Created Collection with Documents

    You will be presented with an empty collection on clicking the artists collection −

    Filling Up Collection with Documents

    To add a document, you need to click the + sign placed in the upper right corner. When you are prompted for a _key, enter Affable_Balding as the key.

    Now, a form will appear to add and edit the attributes of the document. There are two ways of adding attributes: Graphical and Tree. The graphical way is intuitive but slow, therefore, we will switch to the Code view, using the Tree dropdown menu to select it −

    Tree Dropdown menu

    To make the process easier, we have created a sample data in the JSON format, which you can copy and then paste into the query editor area −

    {“artist”: “Johnny Mercer”, “title”:”Affable Balding Me”, “composer”: “Robert Emmett Dolan”, “Year”: 1950}

    (Note: Only one pair of curly braces should be used; see the screenshot below)

    Created Sample Data In JSON Format

    You can observe that we have quoted the keys and also the values in the code view mode. Now, click Save. Upon successful completion, a green flash appears on the page momentarily.

    How to Read Documents

    To read documents, go back to the Collections page.

    When one clicks on the artist collection, a new entry appears.

    How to Update Documents

    It is simple to edit the entries in a document; you just need to click on the row you wish to edit in the document overview. Here again the same query editor will be presented as when creating new documents.

    Removing Documents

    You can delete the documents by pressing the ‘-’ icon. Every document row has this sign at the end. It will prompt you to confirm to avoid unsafe deletion.

    Moreover, for a particular collection, other operations like filtering the documents, managing indexes, and importing data also exist on the Collections Overview page.

    In our subsequent chapter, we will discuss an important feature of the Web Interface, i.e., the AQL query Editor.


    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí ArangoDB – Crud Operations nhận dự án làm có lương

    ArangoDB – Crud Operations



    In this chapter, we will learn the different operations with Arangosh.

    The following are the possible operations with Arangosh −

    • Creating a Document Collection
    • Creating Documents
    • Reading Documents
    • Updating Documents

    Let us start by creating a new database. We will use the following line of code to create a new database −

    127.0.0.1:8529@_system> db._createDatabase("song_collection")
    true
    

    The following line of code will help you shift to the new database −

    127.0.0.1:8529@_system> db._useDatabase("song_collection")
    true
    

    Prompt will shift to “@@song_collection”

    127.0.0.1:8529@song_collection>
    

    Promt Shift Song Collection

    From here we will study CRUD Operations. Let us create a collection into the new database −

    127.0.0.1:8529@song_collection> db._createDocumentCollection(''songs'')
    

    Output

    [ArangoCollection 4890, "songs" (type document, status loaded)]
    127.0.0.1:8529@song_collection>
    

    Let us add a few documents (JSON objects) to our ”songs” collection.

    We add the first document in the following way −

    127.0.0.1:8529@song_collection> db.songs.save({title: "A Man''s Best Friend",
    lyricist: "Johnny Mercer", composer: "Johnny Mercer", Year: 1950, _key:
    "A_Man"})
    

    Output

    {
       "_id" : "songs/A_Man",
       "_key" : "A_Man",
       "_rev" : "_VjVClbW---"
    }
    

    Let us add other documents to the database. This will help us learn the process of querying the data. You can copy these codes and paste the same in Arangosh to emulate the process −

    127.0.0.1:8529@song_collection> db.songs.save(
       {
          title: "Accentchuate The Politics",
          lyricist: "Johnny Mercer",
          composer: "Harold Arlen", Year: 1944,
          _key: "Accentchuate_The"
       }
    )
    
    {
       "_id" : "songs/Accentchuate_The",
       "_key" : "Accentchuate_The",
       "_rev" : "_VjVDnzO---"
    }
    
    127.0.0.1:8529@song_collection> db.songs.save(
       {
          title: "Affable Balding Me",
          lyricist: "Johnny Mercer",
          composer: "Robert Emmett Dolan",
          Year: 1950,
          _key: "Affable_Balding"
       }
    )
    {
       "_id" : "songs/Affable_Balding",
       "_key" : "Affable_Balding",
       "_rev" : "_VjVEFMm---"
    }
    

    How to Read Documents

    The _key or the document handle can be used to retrieve a document. Use document handle if there is no need to traverse the collection itself. If you have a collection, the document function is easy to use −

    127.0.0.1:8529@song_collection> db.songs.document("A_Man");
    {
       "_key" : "A_Man",
       "_id" : "songs/A_Man",
       "_rev" : "_VjVClbW---",
       "title" : "A Man''s Best Friend",
       "lyricist" : "Johnny Mercer",
       "composer" : "Johnny Mercer",
       "Year" : 1950
    }
    

    How to Update Documents

    Two options are available to update the saved data − replace and update.

    The update function patches a document, merging it with the given attributes. On the other hand, the replace function will replace the previous document with a new one. The replacement will still occur even if completely different attributes are provided. We will first observe a non-destructive update, updating the attribute Production` in a song −

    127.0.0.1:8529@song_collection> db.songs.update("songs/A_Man",{production:
    "Top Banana"});
    

    Output

    {
       "_id" : "songs/A_Man",
       "_key" : "A_Man",
       "_rev" : "_VjVOcqe---",
       "_oldRev" : "_VjVClbW---"
    }
    

    Let us now read the updated song”s attributes −

    127.0.0.1:8529@song_collection> db.songs.document(''A_Man'');
    

    Output

    {
       "_key" : "A_Man",
       "_id" : "songs/A_Man",
       "_rev" : "_VjVOcqe---",
       "title" : "A Man''s Best Friend",
       "lyricist" : "Johnny Mercer",
       "composer" : "Johnny Mercer",
       "Year" : 1950,
       "production" : "Top Banana"
    }
    

    A large document can be easily updated with the update function, especially when the attributes are very few.

    In contrast, the replace function will abolish your data on using it with the same document.

    127.0.0.1:8529@song_collection> db.songs.replace("songs/A_Man",{production:
    "Top Banana"});
    

    Let us now check the song we have just updated with the following line of code −

    127.0.0.1:8529@song_collection> db.songs.document(''A_Man'');
    

    Output

    {
       "_key" : "A_Man",
       "_id" : "songs/A_Man",
       "_rev" : "_VjVRhOq---",
       "production" : "Top Banana"
    }
    

    Now, you can observe that the document no longer has the original data.

    How to Remove Documents

    The remove function is used in combination with the document handle to remove a document from a collection −

    127.0.0.1:8529@song_collection> db.songs.remove(''A_Man'');
    

    Let us now check the song”s attributes we just removed by using the following line of code −

    127.0.0.1:8529@song_collection> db.songs.document(''A_Man'');
    

    We will get an exception error like the following as an output −

    JavaScript exception in file
    ''/usr/share/arangodb3/js/client/modules/@arangodb/arangosh.js'' at 97,7:
    ArangoError 1202: document not found
    ! throw error;
    ! ^
    stacktrace: ArangoError: document not found
    
    at Object.exports.checkRequestResult
    (/usr/share/arangodb3/js/client/modules/@arangodb/arangosh.js:95:21)
    
    at ArangoCollection.document
    (/usr/share/arangodb3/js/client/modules/@arangodb/arango-collection.js:667:12)
    at <shell command>:1:10
    

    Exception Error Output Screen


    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí A Multi-Model First Database nhận dự án làm có lương

    ArangoDB – A Multi-Model First Database



    ArangoDB is hailed as a native multi-model database by its developers. This is unlike other NoSQL databases. In this database, the data can be stored as documents, key/value pairs or graphs. And with a single declarative query language, any or all of your data can be accessed. Moreover, different models can be combined in a single query. And, owing to its multi-model style, one can make lean applications, which will be scalable horizontally with any or all of the three data models.

    Layered vs. Native Multi-Model Databases

    In this section, we will highlight a crucial difference between native and layered multimodel databases.

    Many database vendors call their product “multi-model,” but adding a graph layer to a key/value or document store does not qualify as native multi-model.

    With ArangoDB, the same core with the same query language, one can club together different data models and features in a single query, as we have already stated in previous section. In ArangoDB, there is no “switching” between data models, and there is no shifting of data from A to B to execute queries. It leads to performance advantages to ArangoDB in comparison to the “layered” approaches.

    The Need for Multimodal Database

    Interpreting the [Fowler’s] basic idea leads us to realize the benefits of using a variety of appropriate data models for different parts of the persistence layer, the layer being part of the larger software architecture.

    According to this, one might, for example, use a relational database to persist structured, tabular data; a document store for unstructured, object-like data; a key/value store for a hash table; and a graph database for highly linked referential data.

    However, traditional implementation of this approach will lead one to use multiple databases in the same project. It can lead to some operational friction (more complicated deployment, more frequent upgrades) as well as data consistency and duplication issues.

    The next challenge after unifying the data for the three data models, is to devise and implement a common query language that can allow data administrators to express a variety of queries, such as document queries, key/value lookups, graphy queries, and arbitrary combinations of these.

    By graphy queries, we mean queries involving graph-theoretic considerations. In particular, these may involve the particular connectivity features coming from the edges. For example, ShortestPath, GraphTraversal, and Neighbors.

    Graphs are a perfect fit as data model for relations. In many real-world cases such as social network, recommendor system, etc., a very natural data model is a graph. It captures relations and can hold label information with each edge and with each vertex. Further, JSON documents are a natural fit to store this type of vertex and edge data.

    ArangoDB ─ Features

    There are various notable features of ArangoDB. We will highlight the prominent features below −

    • Multi-model Paradigm
    • ACID Properties
    • HTTP API

    ArangoDB supports all popular database models. Following are a few models supported by ArangoDB −

    • Document model
    • Key/Value model
    • Graph model

    A single query language is enough to retrieve data out of the database

    The four properties Atomicity, Consistency, Isolation, and Durability (ACID) describe the guarantees of database transactions. ArangoDB supports ACID-compliant transactions.

    ArangoDB allows clients, such as browsers, to interact with the database with HTTP API, the API being resource-oriented and extendable with JavaScript.


    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí Basic Concepts & Terminologies nhận dự án làm có lương

    Basic Concepts and Terminologies



    In this chapter, we will discuss the basic concepts and terminologies for ArangoDB. It is very important to have a knowhow of the underlying basic terminologies related to the technical topic we are dealing with.

    The terminologies for ArangoDB are listed below −

    • Document
    • Collection
    • Collection Identifier
    • Collection Name
    • Database
    • Database Name
    • Database Organization

    From the perspective of data model, ArangoDB may be considered a document-oriented database, as the notion of a document is the mathematical idea of the latter. Document-oriented databases are one of the main categories of NoSQL databases.

    The hierarchy goes like this: Documents are grouped into collections, and Collections exist inside databases

    It should be obvious that Identifier and Name are two attributes for the collection and database.

    Usually, two documents (vertices) stored in document collections are linked by a document (edge) stored in an edge collection. This is ArangoDB”s graph data model. It follows the mathematical concept of a directed, labeled graph, except that edges don”t just have labels, but are full-blown documents.

    Having become familiar with the core terms for this database, we begin to understand ArangoDB”s graph data model. In this model, there exist two types of collections: document collections and edge collections. Edge collections store documents and also include two special attributes: first is the _from attribute, and the second is the _to attribute. These attributes are used to create edges (relations) between documents essential for graph database. Document collections are also called vertex collections in the context of graphs (see any graph theory book).

    Let us now see how important databases are. They are important because collections exist inside databases. In one instance of ArangoDB, there can be one or many databases. Different databases are usually used for multi-tenant setups, as the different sets of data inside them (collections, documents, etc.) are isolated from one another. The default database _system is special, because it cannot be removed. Users are managed in this database, and their credentials are valid for all the databases of a server instance.


    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí ArangoDB – Home nhận dự án làm có lương

    ArangoDB tutorial

    ArangoDB Tutorial







    Apparently, the world is becoming more and more connected. And at some point in the very near future, your kitchen bar may well be able to recommend your favorite brands of whiskey! This recommended information may come from retailers, or equally likely it can be suggested from friends on Social Networks; whatever it is, you will be able to see the benefits of using graph databases, if you like the recommendations. This tutorial explains the various aspects of ArangoDB which is a major contender in the landscape of graph databases. Starting with the basics of ArangoDB which focuses on the installation and basic concepts of ArangoDB, it gradually moves on to advanced topics such as CRUD operations and AQL. The last few chapters in this tutorial will help you understand how to deploy ArangoDB as a single instance and/or using Docker.

    Audience

    This tutorial is meant for those who are interested in learning ArangoDB as a Multimodel Database. Graph databases are spreading like wildfire across the industry and are making an impact on the development of new generation applications. So anyone who is interested in learning different aspects of ArangoDB, should go through this tutorial.

    Prerequisites

    Before proceeding with this tutorial, you should have the basic knowledge of Database, SQL, Graph Theory, and JavaScript.

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí Data Models & Modeling nhận dự án làm có lương

    ArangoDB – Data Models and Modeling



    In this chapter, we will focus on the following topics −

    • Database Interaction
    • Data Model
    • Data Retrieval

    ArangoDB supports document based data model as well as graph based data model. Let us first describe the document based data model.

    ArangoDB”s documents closely resemble the JSON format. Zero or more attributes are contained in a document, and a value attached with each attribute. A value is either of an atomic type, such as a number, Boolean or null, literal string, or of a compound data type, such as embedded document/object or an array. Arrays or sub-objects may consist of these data types, which implies that a single document can represent non-trivial data structures.

    Further in hierarchy, documents are arranged into collections, which may contain no documents (in theory) or more than one document. One can compare documents to rows and collections to tables (Here tables and rows refer to those of relational database management systems – RDBMS).

    But, in RDBMS, defining columns is a prerequisite to store records into a table, calling these definitions schemas. However, as a novel feature, ArangoDB is schema-less – there is no a priori reason to specify what attributes the document will have.

    And unlike RDBMS, each document can be structured in a completely different way from another document. These documents can be saved together in one single collection. Practically, common characteristics may exist among documents in the collection, however the database system, i.e., ArangoDB itself, does not bind you to a particular data structure.

    Now we will try to understand ArangoDB”s [graph data model], which requires two kinds of collections — the first is the document collections (known as vertices collections in group-theoretic language), the second is the edge collections. There is a subtle difference between these two types. Edge collections also store documents, but they are characterized by including two unique attributes, _from and _to for creating relations between documents. In practice, a document (read edge) links two documents (read vertices), both stored in their respective collections. This architecture is derived from the graph-theoretic concept of a labeled, directed graph, excluding edges that can have not only labels, but can be a complete JSON like document in itself.

    To compute fresh data, delete documents or to manipulate them, queries are used, which select or filter documents as per the given criteria. Either being simple as an “example query” or being as complex as “joins”, queries are coded in AQL – ArangoDB Query Language.


    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí ArangoDB – Web Interface nhận dự án làm có lương

    ArangoDB – Web Interface



    In this chapter, we will learn how to enable/disable the Authentication, and how to bind the ArangoDB to the Public Network Interface.

    # arangosh --server.endpoint tcp://127.0.0.1:8529 --server.database "_system"
    

    It will prompt you for the password saved earlier −

    Please specify a password:
    

    Use the password you created for root, at the configuration.

    You can also use curl to check that you are actually getting HTTP 401 (Unauthorized) server responses for requests that require authentication −

    # curl --dump - http://127.0.0.1:8529/_api/version
    

    Output

    HTTP/1.1 401 Unauthorized
    X-Content-Type-Options: nosniff
    Www-Authenticate: Bearer token_type = "JWT", realm = "ArangoDB"
    Server: ArangoDB
    Connection: Keep-Alive
    Content-Type: text/plain; charset = utf-8
    Content-Length: 0
    

    To avoid entering the password each time during our learning process, we will disable the authentication. For that, open the configuration file −

    # vim /etc/arangodb3/arangod.conf
    

    You should change the color scheme if the code is not properly visible.

    :colorscheme desert
    

    Set authentication to false as shown in the screenshot below.

    Output Window Root Password

    Restart the service −

    # service arangodb3 restart
    

    On making the authentication false, you will be able to login (either with root or created user like Harry in this case) without entering any password in please specify a password.

    Let us check the api version when the authentication is switched off −

    # curl --dump - http://127.0.0.1:8529/_api/version
    

    Output

    HTTP/1.1 200 OK
    X-Content-Type-Options: nosniff
    Server: ArangoDB
    Connection: Keep-Alive
    Content-Type: application/json; charset=utf-8
    Content-Length: 60
    {"server":"arango","version":"3.1.27","license":"community"}
    

    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc

  • Khóa học miễn phí ArangoDB – Advantages nhận dự án làm có lương

    ArangoDB – Advantages



    Following are the advantages of using ArangoDB −

    Consolidation

    As a native multi-model database, ArangoDB eliminates the need to deploy multiple databases, and thus decreases the number of components and their maintenance. Consequently, it reduces the technology-stack complexity for the application. In addition to consolidating your overall technical needs, this simplification leads to lower total cost of ownership and increasing flexibility.

    Simplified Performance Scaling

    With applications growing over time, ArangoDB can tackle growing performance and storage needs, by independently scaling with different data models. As ArangoDB can scale both vertically and horizontally, so in case when your performance demands a decrease (a deliberate, desired slow-down), your back-end system can be easily scaled down to save on hardware as well as operational costs.

    Reduced Operational Complexity

    The decree of Polyglot Persistence is to employ the best tools for every job you undertake. Certain tasks need a document database, while others may need a graph database. As a result of working with single-model databases, it can lead to multiple operational challenges. Integrating single-model databases is a difficult job in itself. But the biggest challenge is building a large cohesive structure with data consistency and fault tolerance between separate, unrelated database systems. It may prove nearly impossible.

    Polyglot Persistence can be handled with a native multi-model database, as it allows to have polyglot data easily, but at the same time with data consistency on a fault tolerant system. With ArangoDB, we can use the correct data model for the complex job.

    Strong Data Consistency

    If one uses multiple single-model databases, data consistency can become an issue. These databases aren’t designed to communicate with each other, therefore some form of transaction functionality needs to be implemented to keep your data consistent between different models.

    Supporting ACID transactions, ArangoDB manages your different data models with a single back-end, providing strong consistency on a single instance, and atomic operations when operating in cluster mode.

    Fault Tolerance

    It is a challenge to build fault tolerant systems with many unrelated components. This challenge becomes more complex when working with clusters. Expertise is required to deploy and maintain such systems, using different technologies and/or technology stacks. Moreover, integrating multiple subsystems, designed to run independently, inflict large engineering and operational costs.

    As a consolidated technology stack, multi-model database presents an elegant solution. Designed to enable modern, modular architectures with different data models, ArangoDB works for cluster usage as well.

    Lower Total Cost of Ownership

    Each database technology requires ongoing maintenance, bug fixing patches, and other code changes which are provided by the vendor. Embracing a multi-model database significantly reduces the related maintenance costs simply by eliminating the number of database technologies in designing an application.

    Transactions

    Providing transactional guarantees throughout multiple machines is a real challenge, and few NoSQL databases give these guarantees. Being native multi-model, ArangoDB imposes transactions to guarantee data consistency.


    Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc