PostgreSQL NoSQL and integration between relational and non-relational databases

3

I've been searching for PostgreSQL NoSQL and found the Key-Value Stores concept in some HSTORE publications. I also looked into the integration between PostgreSQL and the Spring framework and found the following code example:

package com.jamesward.model;

import net.backtothefront.HstoreUserType;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.util.HashMap;
import java.util.Map;

@Entity
@TypeDef(name = "hstore", typeClass = HstoreUserType.class)
public class Contact {

    @Id
    @GeneratedValue
    public Integer id;

    @Column(nullable = false)
    public String name;

    @Type(type = "hstore")
    @Column(columnDefinition = "hstore")
    public Map<String, String> contactMethods = new HashMap<String, String>();

}

As you can see in this entity there are 3 (three) fields id Integer, name String type and contactMethods which is the field where JSON will be stored.

And searching in an EnterpriseDB PDF I found the following command for creating a table with a single field only named json_data which will store JSONB type values.

CREATE TABLE json_data (data JSONB);

In addition to a SELECT like this (besides INSERT and other actions using this entity that can be found in the references published at the end of the question):

SELECT DISTINCT 
data->>'name' AS "Product Name",
data->>'price' AS "price"  
FROM json_data 
WHERE data->>'brand' = 'ACME';

And what I would like to know is based on these questions:

  • Can I make PostgreSQL tables all NoSQL? That is, only with a JSON field and not two or more fields being one identifier and the other JSON, for example as seen previously in one of the above codes.
  • When the table has multiple records and clients using the query and the Key-Value concept will it be slow even if you have created more fields for the table?
  • Using only one field of type JSON in the entity would be able to work correctly with Spring or is it even necessary to have one or more fields being one identifier and the other JSON? Would not Spring be able to read multi-line records with just one JSON type field as if it were document oriented like MongoDB, Cassandra, Hadoop?
  • One of the last three questions, and I believe the most important one, can I make a PostgreSQL database completely NoSQL, whereas in the EnterpriseDB example I have created only one field? Substituting in this way the use of the main non-relational banks?
  • If not, what is the need to create a JSON field storing, such as name, cpf, rg if we can create multiple fields to store each of these attributes?
  • I also read that an application can use relational and non-relational databases together, without problems, how is this integration made? I saw in Oracle SQL Developer, in the left menu, that it has a NoSQL item, but it was never used.
  • References:

    EnterpriseDB - Using the NoSQL Capabilities in Postgres

    James Ward - NoSQL Inside SQL with Java, Spring, Hibernate, and PostgreSQL

    James Ward - NoSQL Inside SQL with Java, Spring, Hibernate, and PostgreSQL (GitHub repository)

        
    asked by anonymous 01.11.2015 / 17:04

    0 answers