Create and manage a database with multiple schema on SQL server

Creating a demo database

Follow the following step to create a database on-premises:

  1. Download SQL server on your local machine.
  2. After installation, connect to it using SQL Server Management Studo. To download SQL Server Management Studio, kindly go to this link:
  3. Now you have connection to database, the default schema is "dbo", if you don't specify any schema, you will automatically create for example a table under "dbo" schema.

The goal is we plan to create a schema for each client and only that client can access it's own schema, not any clients else. Under each schema, there should be exactly the same tables as what we have currently on cloud.

  • Create authentication users:

In the Database User - New dialog box, on the General page, select one of the following user types from the User type list:

  • SQL user with login
  • SQL user with password
  • SQL user without login
  • User mapped to a certificate
  • User mapped to an asymmetric key
  • Windows user

Read More

Single database with multiple schemas VS. Multiple databases with single schema

Single Database with multiple schemas

There are couple of questions that might help us decide: (

  • Are most users in the same location or using the same access path?
  • Do the applications have the same administrative support staff?
  • Do the applications have compatible availability requirements?
  • Do the applications have compatible database and OS version requirements and upgrade paths?
  • Are the applications reasonably similar in functionality and load characteristics?
  • Do the applications have the same usage level (e.g., QA, development, production, maintenance, etc.)?
  • If the data is related and you want to enforce referential integrity and implement Foreign Keys
  • If you could ever want a foreign key constraint between the two entities

We better consider placing different schemas in the same database if we answer "Yes" to all questions (or most of them).

Read More

Inventory Management Web Development (Django)

Inventory Management Sprint 13

Tech Stack

For back-end, we use:

  • Django: back-end server
  • GCP Compute Engine: where web app hosted
  • Email Notification and Food Freshness Detection Python Scripts

For Front-end side:

  • Bootstrap: providing style thing
  • JavaScript: handle dynamic elements
  • web development

    Basically I have three parts: stock management, food freshness and donation. I’ve done with creating a homepage to navigate the three separate apps. For food freshness and and donation, the pages has been created.

Integrate back-end and front-end

Deal with database migrate

error message: Unknown command: “squall”

This is caused by squall has been deprecated since Django 1.9, currently we use Django 3.0.8. To solve this, do the following commands:

python3 makemigrations your_app_name
python3 migrate
python3 sqlmigrate freshness 0001

How to connect MySQL database through Django Shell

First you’ll need to configure the database’s name, host, password in under your apps

Type following command to invoke Django Shell:

Python3 shell

Then type your command to the shell:

>>> from Django.db import connection
>>> cursor = connection.cursor()
>>> cursor.execute('SELECT item FROM freshness_food ORDER BY item')
>>> print(cursor.fetchall())

above is just an example

Cassandra in Java

This tutorial is an introductory guide to the Apache Cassandra database using Java.

Apache Cassandra

what do you know about Cassandra?

Cassandra is a scalable NoSQL database that provides continuous availability with no single point of failure and gives the ability to handle large amounts of data with exceptional performance.

This database uses a ring design instead of using a master-slave architecture. In the ring design, there is no master node – all participating nodes are identical and communicate with each other as peers.

This makes Cassandra a horizontally scalable system by allowing for the incremental addition of nodes without needing reconfiguration.

Key Concepts

  • Cluster: a collection of nodes or Data Centers arranged in a ring architecture. A name must be assigned to every cluster, which will subsequently be used by the participating nodes
  • Keyspace: If you are coming from a relational database, then the schema is the respective keyspace in Cassandra. The keyspace is the outermost container for data in Cassandra. The main attributes to set per keyspace are the Replication Factor, the Replica Placement Strategy and the Column Families
  • Column Family: Column Families in Cassandra are like tables in Relational Databases. Each Column Family contains a collection of rows which are represented by a Map<RowKey, SortedMap<ColumnKey, ColumnValue». The key gives the ability to access related data together
  • Column: A column in Cassandra is a data structure which contains a column name, a value and a timestamp. The columns and the number of columns in each row may vary in contrast with a relational database where data are well structured

Monotone Stack

What is monotonous increase stack?

The elements in the an monotonous increase stack keeps an increasing order.

The typical paradigm for monotonous increase stack:

for(int i = 0; i < A.size(); i++){
  while(!in_stk.empty() && > A[i]){

Read More

Sorting Code In Java

sort algorithm in java

Bubble sort

public static void bubblesort(int[] array){
	boolean sorted = false;
	int temp;
		sorted = true;
		for(int i = 0; i < array.length - 1; i++){
			if(array[i] > array[i+1]){
				temp = array[i];
				array[i] = array[i+1];
				array[i+1] = temp;
				sorted = false;

Alt Text

Read More

Cookies Intro


Different type of cookies

Session cookies Basically when you close the website, the cookies will be removed from your growers, so its risk is relatively low.

Photo by Dustin Lee.

Persistent cookies Even when you close your browser, the cookies will still be stored on it. And each time you return to the website that created this cookie, or you go to a website that has a resource produced by the cookie’s issuer (eg, an ad), this data is returned to the issuer.

Read More

Pre/In/Post order

Markdown (or Textile), Liquid, HTML & CSS go in. Static sites come out ready for deployment.

binary tree traversal




  1. 先将根结点入栈

  2. 出栈一个元素,将右节点和左节点依次入栈

  3. 重复 2 的步骤

总结: 典型的递归数据结构,典型的用栈来简化操作的算法。

Read More

C++ API docs

First, pointers and reference


  • Pointer variables are declared using the unary suffix declarator operator *
  • Pointer objects are assigned an address value, for example, by assignment to an array object, the address of an object using the & unary prefix operator, or assignment to the value of another pointer object
  • A pointer can be reassigned any number of times, pointing to different objects
  • A pointer is a variable that holds the assigned address. It takes up storage in memory equal to the size of the address for the target machine architecture
  • A pointer can be mathematically manipulated, for instance, by the increment or addition operators. Hence, one can iterate with a pointer, etc.
  • To get or set the contents of the object referred to by a pointer, one must use the unary prefix operator * to dereference it

Read More