Dylan  Iqbal

Dylan Iqbal

1560762127

The basics of NoSQL databases — and why we need them

The basics of NoSQL databases — and why we need them. A beginner’s guide to the NoSQL world.

Organizing data is a very difficult task. When we say organise, we are actually categorising stuff depending on its type and function.

One option is RDBMS is like an Excel Sheet — you categorise data in the form of tables. You can form relationships between the tables.

A query questions the database, which gives you a relevant answer in return. This querying language is SQL or Structured Query Language.

For example,

select * from Employee_Data;

selects all the Employee Data from the Employee_Data table.

Relational databases follow a schema, a detailed blueprint of how your tables work.

You use Amazon, Facebook and so many networking applications. They release updates, add new functionalities and even extra modules. So how does one change the schema each time? Isn’t it time consuming for such huge companies to devote their time and labour to changing the schema?

This is where SQL could not work.

The Cons of RDBMS

Relational databases aren’t as bad as people portray these days. They are still in use by plenty of organisations. The introduction of NoSQL into the picture is to fill up the spaces where RDBMS can’t be of use anymore.

I am going to show you examples so that you have a clear understanding.

1. RDBMS can not handle ‘Data Variety’.

The amount of unstructured data continues to increase yearly and managing it is hard. RDBMS can’t force all types of data under a unified schema of tables.

Data Silos are also a problem for developers.

According to Tech Target, a data silo is a repository of data that remains under the control of one department. It is isolated from the rest of the organisation.

This means that when more silos exist for the same data, their contents are likely to differ. It creates confusion on which repository represents the most up-to-date version.

The increase of data from the year 2013 to 2020 is visible in the image below.

Handling such diverse data which aren’t related to each other could be much harder in RDBMS.

Example: It is difficult to store the details of a patient, who has varying body conditions. Categorisation of such diverse data is difficult in RDBMS.

2. Difficult to change tables and relationships.

Alteration of the relationships between tables or addition of a new table could affect the existing relations. This means changing the schema.

Change of the schema would be like eliminating the existing one and devising a new schema.

Addition of a new functionality would need all the elements to support the new structure. Change is inevitable.

Example: Each extra column needs all the prior rows to have values for that column. Whereas in Cassandra (a NoSQL database), you can add a column to specific row partitions.

3. RDBMS follow the ACID properties of the database.

The ACID properties of a database are Atomicity, Consistency, Isolation and Durability. ‌

Atomicity — An “all or nothing” approach. If any statement in the transaction fails, the entire transaction is rolled back.

**Consistency — **The transaction must meet all protocols defined by the system. No half completed transactions.

**Isolation — **No transaction has access to any other transaction that is in an intermediate or unfinished state. Each transaction is independent.

**Durability **— Ensures that once a transaction commits to the database, it is preserved through the use of backups and transaction logs.

The ACID properties aren’t flexible.

For example, RDBMS follows Normalization or a single point of truth concept. For every change you make, you should ensure strict ACID properties. The entity integrity and referential integrity rules also apply.

The CAP Theorem

According to Wikipedia, the CAP theorem (Brewer’s theorem) states that it is impossible for a distributed data store to simultaneously provide more than two out of the following three guarantees:

Consistency: Like the C in ACID.

Availability: ‌Resources should be always available. There should be a non error response.

Partition tolerance: No single point (or node) of failure.

It is difficult to achieve all the three conditions. One must compromise between the three.

BASE to the rescue!

‌NoSQL relies upon a softer model known as the BASE model. BASE (Basically Available, Soft state, Eventual consistency).

Basically Available: Guarantees the availability of the data . There will be a response to any request (can be failure too).

Soft state: The state of the system could change over time.

Eventual consistency: The system will eventually become consistent once it stops receiving input.

NoSQL databases give up the A, C and/or D requirements, and in return they improve scalability.

NoSQL

This is when NoSQL came to the rescue.‌ It is “Not Only SQL” or “Non-relational” databases.

Characteristics of NoSQL:

  • Schema free
  • Eventually consistent (as in the BASE property)
  • Replication of data stores to avoid Single Point of Failure.
  • Can handle Data variety and huge amounts of data.

Types of NoSQL databases

NoSQL databases fall into four main categories:

**Key value Stores — **Riak, Voldemort, and Redis

**Wide Column Stores — **Cassandra and HBase.

**Document databases — **MongoDB

**Graph databases **— Neo4J and HyperGraphDB.

The words to the right hand side are examples of the types of NoSQL database types.

1. Key Value Stores

A key value store uses a hash table in which there exists a unique key and a pointer to a particular item of data.

Imagine key value stores to be like a phone directory where the names of the individual and their numbers are mapped together.

Key value stores have no default query language. You retrieve data using get, put, and delete commands. This is the reason it has high performance.

Applications: Useful for storage of Comments and Session information. ‌Pinterest uses Redis to store lists of users, followers, unfollowers, boards.

2. Wide column stores

In a column store database, the columns in each row are contained within that row.

Each column family is a container of rows in an RDBMS table. The key identifies the row consisting of multiple columns.

Rows do not need to have the same number of columns. Columns can be added to any row at any time without having to add it to other rows. It is a partitioned row store.

How does a columnar database store data?

Applications: Spotify uses Cassandra to store user profile attributes and metadata.

3. Document Databases

‌Document stores uses JSON, XML, or BSON (binary encoding of JSON) documents to store data.

It is like a key-value database, but a document store consists of semi-structured data.

A single document is to store records and its data.

‌It does not support relations or joins.

If we want to store the customer details and their orders, we can use document stores to do it.

Applications: ‌SEGAuses MongoDB for handling 11 million in-game accounts built on MongoDB.

4. Graph databases

‌Nodes and relationships are the essential constituents of graph databases. A node represents an entity. A relationship represents how two nodes are associated.

‌In RDBMS, adding another relation results in a lot of schema changes.

Graph database requires only storing data once (nodes). The different types of relationships (edges) are specified to the stored data.

The relationships between the nodes are predetermined, that is, it is not determined at query time.

Traversing persisted relationships are faster.

It is difficult to change a relation between two nodes. It would result in regressive changes in the database.

Example: This image is how MySQL works where it has to perform many operations to find a correct result for Alice.

A graph database, which predetermines relationships.

This is some of the basic information you will need to start exploring NoSQL. New databases are being invented for specific uses.

Learn the type of data your application generates, and then it is easy to choose the right database.

Learn More

The Complete SQL Bootcamp

The Complete Oracle SQL Certification Course

SQL for Newbs: Data Analysis for Beginners

The Ultimate MySQL Bootcamp: Go from SQL Beginner to Expert

Microsoft SQL for Beginners

SQL - MySQL for Data Analytics and Business Intelligence

SQL & Database Design A-Z™: Learn MS SQL Server + PostgreSQL

#database #sql

What is GEEK

Buddha Community

Kole  Haag

Kole Haag

1602403200

What is NoSQL and How is it Utilized?

Posted on September 25, 2020 by Dean Conally | Updated: October 8, 2020

Category: Tutorials | Tags: CassandraColumnsDatabaseDatabase ManagementDatabase StructureDB2Document StoresDynamic SchemaExtensible Record StoresGraph StoresJSONKey-ValueMSSQLMulti-RowMySQLNodeNode Relationship NodeNon-Relational DatabasesNoSQLNoSQL ModelQueryRowsScalabilitySchema FreeSQLStoresTablesWide-Column

Reading Time: 5 minutes

What is NoSQL?

A NoSQL or a NoSQL Database is a term used when referring to a “non SQL” or “not only SQL” database. NoSQL databases store data in a different format than a traditional relational database management systems. This is why NoSQL is often associated with the term “non-relational” database. Simply put, NoSQL databases are modern databases with high flexibility, blazing performance, and built for scalability. These databases are used when you require low latency and high extensibility while working with large data structures. The versatility of NoSQL is due to the nature of as being unrestricted in comparison to relational databases models such as MySQL or DB2.

SQL vs. NoSQL Comparison

There are multiple differences between SQL and NoSQL database types. In the table below, we will compare some of the most critical variations.

#tutorials #cassandra #columns #database #database management #database structure #db2 #document stores #dynamic schema #extensible record stores #graph stores #json #key-value #mssql #multi-row #mysql #node #node relationship node #non-relational databases #nosql #nosql model #query #rows #scalability #schema free #sql #stores #tables #wide-column

Ruth  Nabimanya

Ruth Nabimanya

1620633584

System Databases in SQL Server

Introduction

In SSMS, we many of may noticed System Databases under the Database Folder. But how many of us knows its purpose?. In this article lets discuss about the System Databases in SQL Server.

System Database

Fig. 1 System Databases

There are five system databases, these databases are created while installing SQL Server.

  • Master
  • Model
  • MSDB
  • Tempdb
  • Resource
Master
  • This database contains all the System level Information in SQL Server. The Information in form of Meta data.
  • Because of this master database, we are able to access the SQL Server (On premise SQL Server)
Model
  • This database is used as a template for new databases.
  • Whenever a new database is created, initially a copy of model database is what created as new database.
MSDB
  • This database is where a service called SQL Server Agent stores its data.
  • SQL server Agent is in charge of automation, which includes entities such as jobs, schedules, and alerts.
TempDB
  • The Tempdb is where SQL Server stores temporary data such as work tables, sort space, row versioning information and etc.
  • User can create their own version of temporary tables and those are stored in Tempdb.
  • But this database is destroyed and recreated every time when we restart the instance of SQL Server.
Resource
  • The resource database is a hidden, read only database that holds the definitions of all system objects.
  • When we query system object in a database, they appear to reside in the sys schema of the local database, but in actually their definitions reside in the resource db.

#sql server #master system database #model system database #msdb system database #sql server system databases #ssms #system database #system databases in sql server #tempdb system database

Ruth  Nabimanya

Ruth Nabimanya

1620648300

What is SQL? And Where is it Used?

Define: SQL [pron. “sequel”] – stands for Structured Query Language (SQL), used by databases to model and manage tabular/relational datasets; a set of standardized Data Definition Language (DDL) functions to create tables, views, and define relational schema models, and Data Manipulation Language (DML) to query, insert, and modify data in the tables.

*Read-only select queries are technically part of its Data Query Language (DQL) group. Still, operationally, many refer to it as DML because it can do more than read-only queries.

Super Brief History of SQL

Who Uses SQL?

What Can a SQL Database Do?

What is a SQL Query?

Different SQL Database Platforms

SQL for JSON

Application Developers

SQL for Big Data

Further Reading

#sql #database #relational-database #nosql #json #sql-database #database-administration #databases-best-practices

Django-allauth: A simple Boilerplate to Setup Authentication

Django-Authentication 

A simple Boilerplate to Setup Authentication using Django-allauth, with a custom template for login and registration using django-crispy-forms.

Getting Started

Prerequisites

  • Python 3.8.6 or higher

Project setup

# clone the repo
$ git clone https://github.com/yezz123/Django-Authentication

# move to the project folder
$ cd Django-Authentication

Creating virtual environment

  • Create a virtual environment for this project:
# creating pipenv environment for python 3
$ virtualenv venv

# activating the pipenv environment
$ cd venv/bin #windows environment you activate from Scripts folder

# if you have multiple python 3 versions installed then
$ source ./activate

Configured Enviromment

Environment variables

SECRET_KEY = #random string
DEBUG = #True or False
ALLOWED_HOSTS = #localhost
DATABASE_NAME = #database name (You can just use the default if you want to use SQLite)
DATABASE_USER = #database user for postgres
DATABASE_PASSWORD = #database password for postgres
DATABASE_HOST = #database host for postgres
DATABASE_PORT = #database port for postgres
ACCOUNT_EMAIL_VERIFICATION = #mandatory or optional
EMAIL_BACKEND = #email backend
EMAIL_HOST = #email host
EMAIL_HOST_PASSWORD = #email host password
EMAIL_USE_TLS = # if your email use tls
EMAIL_PORT = #email port

change all the environment variables in the .env.sample and don't forget to rename it to .env.

Run the project

After Setup the environment, you can run the project using the Makefile provided in the project folder.

help:
 @echo "Targets:"
 @echo "    make install" #install requirements
 @echo "    make makemigrations" #prepare migrations
 @echo "    make migrations" #migrate database
 @echo "    make createsuperuser" #create superuser
 @echo "    make run_server" #run the server
 @echo "    make lint" #lint the code using black
 @echo "    make test" #run the tests using Pytest

Preconfigured Packages

Includes preconfigured packages to kick start Django-Authentication by just setting appropriate configuration.

PackageUsage
django-allauthIntegrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication.
django-crispy-formsdjango-crispy-forms provides you with a crispy filter and {% crispy %} tag that will let you control the rendering behavior of your Django forms in a very elegant and DRY way.

Contributing

  • Django-Authentication is a simple project, so you can contribute to it by just adding your code to the project to improve it.
  • If you have any questions, please feel free to open an issue or create a pull request.

Download Details:
Author: yezz123
Source Code: https://github.com/yezz123/Django-Authentication
License: MIT License

#django #python