Ruth  Nabimanya

Ruth Nabimanya

1634236020

How to Manage Database Schema via Liquibase for Beginner in 2021

One open-source tool that helps teams track, version, and deploy database schema changes is Liquibase. It executes database scripts sequentially, allows for the automatic creation and execution of rollback scripts for failed updates, and provides an easy way to use the same scripts and apply them to different types of databases.

#database

What is GEEK

Buddha Community

How to Manage Database Schema via Liquibase for Beginner in 2021
Brain  Crist

Brain Crist

1600347600

SCHEMAS in SQL Server -MS SQL Server – Zero to Hero Query Master

Introduction

This is part 3 of “MS SQL Server- Zero to Hero” and in this article, we will be discussing about the SCHEMAS in SQL SERVER. Before getting into this article, please consider to visit previous articles in this series from below,

A glimpse of previous articles
Part 1

In part one, we learned the basics of data, database, database management system, and types of DBMS and SQL.

Part 2
  • We learned to create a database and maintain it using SQL statements.
  • Best practice methods were also mentioned.

#sql server #benefits of schemas #create schema in sql #database schemas #how to create schema in sql server #schemas #schemas in sql server #sql server schemas #what is schema in sql server

Fredy  Larson

Fredy Larson

1601480520

Database Schema Versioning and Migrations Made Simpler For High Speed CI/CD

If you are a back-end developer, you are often faced with having to migrate your database schema with each new release.

The framework called Liquibase can make it easier for you when you need to upgrade your database schema.

In this article, I’ll explain how Liquibase can be used in a Java project, with Spring/Hibernate, to version the database schema.

How does Liquibase work?

Changelog

Liquibase works with Changelog files (the list of all the changes, in order, that need to execute to update the database).

There are 4 supported formats for these Changelogs: SQL, XML, YAML, and JSON.

#liquibase #database #versioning #plugins #java #hackernoon-top-story #database-schema-versioning #database-schema-migration

How to Managing Database Schema with Liquibase

What is Liquibase?

First, Liquibase is an open-source database schema change management tool that makes it simple for you to handle database change revisions.

How Does Liquibase Work?

Regardless of your database platform, changes are defined in a platform-neutral language. In essence, you maintain a running list of modifications. And, Liquibase uses its execution engine to make those modifications for you. It requires the appropriate JDBC driver to update the database because it runs on Java. You must also have the most recent JRE installed, of course. You can run Liquibase manually or from any deployment pipeline because it operates from a shell or command line. To maintain consistency and prevent corruption due to wrongly modified changelogs, Liquibase tracks changes using its own tables in your schema. To prevent you from mistakenly executing two updates at once, it “locks” your database while operating.

Where can we use Liquibase?

  • Database schema change using CD
  • Controlling schema change versions
  • Application and database modifications should be deployed simultaneously to ensure consistency.

Liquibase basics – changeLog files

The changeLog files are the foundation of Liquibase usage. A changelog file is an XML document that records every change that needs to be made to update the database. Tag is parsing when we run the Liquibase migrator, the databaseChangeLog>. We can add changeSet> tags to the databaseChangeLog> tag to organize database changes. The ‘id’ and ‘author’ attributes as well as the name of the changelog file classpath serve to identify each changeSet specifically.

Example:

<databaseChangeLog

    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog 

http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">

</databaseChangeLog>

Updating the database

We will examine how to edit the database to add, update, and remove tables, columns, and data. Now that we have a simple changeLog file. By the principle of “one change per changeSet,” it is counseles to create a new changeSet for each distinct insert, update, and delete action. As a result, we use Liquibase to execute a version-based database migration while updating an existing database.

Manipulating database schema and tables

For the most part, you require some fundamental Data Definition Language (DDL) functions to define data structures in databases.

1) Create schema: Since Liquibase is planned to manage objects within the application’s schema, there is no “create schema” tag. However, we can incorporate the creation of a schema into our migration by using a unique SQL statement inside a “SQL” tag.

<changeSet author="asdf" id="1234">

    <sql dbms="h2" endDelimiter=";">

        CREATE SCHEMA schema

    </sql>

</changeSet>

2) Create Table: The following code is added to the databaseChangeLog tag when a table is created:

<changeSet author="asdf" id="1234">

    <createTable tableName="newTable">

        <column type="INT" name="newColumn"/>
 
    </createTable>

</changeSet> 

3) Drop Table: We must mention the table’s name and the schema when deleting a table. We also remove all constraints referring to primary and unique keys in the drop table when cascadeConstraints are set to true. It will after delete the corresponding records in the child table or tables. The database will return an error and won’t drop the table if there is a referential integrity constraint but we don’t set the cascadeConstraints to true.

<changeSet author="asdf" id="1234">

    <dropTable tableName="newTable" schemaName="public"
 
cascadeConstraints="true"/>

</changeSet>

4) Change existing data structure with alter table: The table can be changed by adding, renaming, and dropping columns as well as changing the data type. To change the table’s name, use the tag renameTable.

4) a. Rename Table: We must specify the new table name, the old table name, and the schema name inside the tag “renameTable”.

<changeSet author="asdf" id="1234">

    <renameTable newTableName="newName" oldTableName="table" 

schemaName='schema'/>

</changeSet>

4) b. Rename Column: A column’s data type, new column name, old column name, schema name, and table name must all be provided to rename a column.

<changeSet author="asdf" id="1234">

    <renameColumn columnDataType="varchar(255)" newColumnName="newColumn" 

oldColumnName="column" schemaName="schema" tableName="table"/>

</changeSet>

4) c. Add Column: The schema name, table name, and the name and type of the new column must be included in the inner tag <column> of the tag <addColumn>.

<changeSet author="asdf" id="1234">

    <addColumn schemaName="schema" tableName="table">

        <column name="newColumn" type="varchar(255)"/>

    </addColumn>

</changeSet>

4) d. Drop column: Column name, table name, and schema name must all be specified to delete a column.

<changeSet author="asdf" id="1234">

    <dropColumn columnName="column" tableName="table", schemaName="schema"/>

</changeSet>

4) e. Modify the data type: We need the column name, new data type, schema name, and table name when changing a data type.

<changeSet author="asdf" id="1234">

    <modifyDataType columnName="column" newDataType="int" schemaName="schema"
 
tableName="table"/>

</changeSet>

Liquibase with Maven

To configure and run Liquibase with Maven, we need to add the following configuration to our pom.xml file:

<dependency>

    <groupId>org.liquibase</groupId>

    <artifactId>liquibase-core</artifactId>

    <version>x.x.x</version>

</dependency> 

Maven also enables us to automatically generate a changelog file from:

  • already existing database
mvn liquibase:generateChangeLog
  • the difference between the two databases
mvn liquibase:diff

Conclusion:

In conclusion, in this blog, we have learned about how can we manage databases with the help of Liquibase. I will be covering more topics on Liquibase in my future blogs, stay connected. Happy learning 🙂

For more, you can refer to the Liquibase documentation: https://docs.liquibase.com/home.html

For a more technical blog, you can refer to the Knoldus blog: https://blog.knoldus.com/

Original article source at: https://blog.knoldus.com/

#database #schema #liquibase 

Ruth  Nabimanya

Ruth Nabimanya

1620640920

How to Efficiently Choose the Right Database for Your Applications

Finding the right database solution for your application is not easy. Learn how to efficiently find a database for your applications.

Finding the right database solution for your application is not easy. At iQIYI, one of the largest online video sites in the world, we’re experienced in database selection across several fields: Online Transactional Processing (OLTP), Online Analytical Processing (OLAP), Hybrid Transaction/Analytical Processing (HTAP), SQL, and NoSQL.

Today, I’ll share with you:

  • What criteria to use for selecting a database.
  • What databases we use at iQIYI.
  • Some decision models to help you efficiently pick a database.
  • Tips for choosing your database.

I hope this post can help you easily find the right database for your applications.

#database architecture #database application #database choice #database management system #database management tool

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