Traditional Database Systems

Using database management system we can store and retrieve data efficiently and whenever we require. There are two main types of database management systems i.e.

  1. RDBMS
  2. NoSQL

RDBMS

  1. RDBMS stands for Relational Database Management System.
  2. RDBMS relies on storage of data in a tabular form.
  3. RDBMS tables have an identifier called primary key
  4. RDBMS database supports Normalization
  5. RDBMS defines its own integrity constraint to fulfil ACID (Atomocity, Consistency, Isolation and Durability) properties.
  6. RDBMS stores data values in the form of tables along with relationship between two data values from different tables.
  7. MS-SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access supports concepts of RDBMS
  8. RDBMS is based on the relational model as introduced by E. F. Codd.
  9. RDBMS data is stored in database objects called tables.
  10. Table is a collection of related data entries and it consists of columns and rows.
  11. Tables generally stores only structured data.

Simple Table Representation of RDBMS

database table - rdbms

Python dictionary – clear() : method

Python Dictionary : clear()

  1. In order to remove the all items from the dictionary we use clear().
  2. It does not take any parameter
  3. Method does not return any value.

Syntax

Below syntax is used for clear() method –

dict.clear()

Python Dictionary : clear() Example

#!/usr/bin/python

dict = {'Word1': 'Meaning1', 'Word2': 'Meaning2'};

print ("Dictionary Length : %d" %  len(dict))
dict.clear()
print ("Dictionary Length : %d" %  len(dict))

Output :

After running the program we will get below output –

>>> 
Dictionary Length : 2
Dictionary Length : 0
>>> 

Python Comparison Operators

Python comparison operators are used to compare the two numbers. Python comparison operators are very useful in decision making

Python comparison operators :

#!/usr/bin/python

num1 = 20 > 10;
num2 = 20 < 10;
num3 = 20 == 10;

print ("Line 1 - Value of num1 : ", num1)
print ("Line 1 - Value of num2 : ", num2)
print ("Line 1 - Value of num3 : ", num3)

Output :

>>> 
Line 1 - Value of num1 :  True
Line 1 - Value of num2 :  False
Line 1 - Value of num3 :  False
>>>

Some Python comparison operators

Consider the following values of num1 and num2

num1 = 10
num2 = 5
OperatorExplanationResult
== It returns true if the value of two operands are equal and false if two operands are not equalfalse
!= It returns true if the value of two operands are not equal and false if two operands are equaltrue
> It returns true if the value of left operands is greater than right operand else it returns falsetrue
< It returns true if the value of left operands is less than right operand else it returns falsefalse
>= It returns true if the value of left operands is greater than or equal to right operand else it returns falsetrue
<= It returns true if the value of left operands is less than or equal to right operand else it returns falsefalse

Python Examples : Comparison Operator

Example #1 : Comparison Operator

#!/usr/bin/python

res = 20 == 10;
print ("Line 1 - Value of res : ", res)

res = 20 != 10;
print ("Line 2 - Value of res : ", res)

res = 20 > 10;
print ("Line 3 - Value of res : ", res)

res = 20 < 10;
print ("Line 4 - Value of res : ", res)

res = 20 >= 10;
print ("Line 5 - Value of res : ", res)

res = 20 <= 10;
print ("Line 6 - Value of res : ", res)

Output :

>>> 
Line 1 - Value of res :  False
Line 2 - Value of res :  True
Line 3 - Value of res :  True
Line 4 - Value of res :  False
Line 5 - Value of res :  True
Line 6 - Value of res :  False
>>> 

Example #2 : Comparison Operator

#!/usr/bin/python

num1 = 10
num2 = 5

if(num1 == num2)
   print ("Line 1 - True Condition")
else
   print ("Line 1 - False Condition")

if(num1 != num2)
   print ("Line 2 - True Condition")
else
   print ("Line 2 - False Condition")

if(num1 > num2)
   print ("Line 3 - True Condition")
else
   print ("Line 3 - False Condition")

if(num1 < num2)
   print ("Line 4 - True Condition")
else
   print ("Line 4 - False Condition")

if(num1 >= num2)
   print ("Line 5 - True Condition")
else
   print ("Line 5 - False Condition")

if(num1 <= num2)
   print ("Line 6 - True Condition")
else
   print ("Line 6 - False Condition")

Output :

>>> 
Line 1 - False Condition
Line 2 - True Condition
Line 3 - True Condition
Line 4 - False Condition
Line 5 - True Condition
Line 6 - False Condition
>>> 

Python Assignment Operators

In this chapter we will be learning about Python assignment operators and some compound assignment operators supported in Python

Python Assignment operators :

Python Assignment operator is used for assigning the value of right operand to the left operand.

#!/usr/bin/python

num1 = 10
num2 = 20.20
num3 = 'A'

print ("Line 1 - Value of num1 : ", num1)
print ("Line 2 - Value of num2 : ", num2)
print ("Line 3 - Value of num3 : ", num3)

Output :

>>> 
Line 1 - Value of num1 :  10
Line 2 - Value of num2 :  20.2
Line 3 - Value of num3 :  A
>>> 

Python Compound Assignment Operators

Consider the value of num1 = 10 and num2 = 5

OperatorExplanation
+=Add right operand to left and assigns addition to the left operand
-=Subtract right operand from left and assigns subtraction to the left operand
*=Multiply right operand to left and assigns multiplication to the left operand
/=Divide right operand by left and assigns division to the left operand
%=Divide right operand by left and assigns remainder of division to the left operand
//=Divide right operand by left and assigns results of division to the left operand by removing digits after the decimal point
**=Perform exponential calculation of two operands and then assign result to left operand.

Assignment Arithmetic operator

In these kind of compound assignment operators we are also performing indirect python arithmetic operations.

Example:

#!/usr/bin/python

num1 = 10
num2 = 5
res = num1 + num2

res += num1
print ("Line 1 - Result of + is ", res)

res *= num1
print ("Line 2 - Result of * is ", res)

res /= num1
print ("Line 3 - Result of / is ", res)

res //= num1
print ("Line 4 - Result of // is ", res)

res **= num1
print ("Line 5 - Result of ** is ", res)

res %= num1
print ("Line 6 - Result of % is ", res)

res -= num1
print ("Line 7 - Result of - is ", res)

Output :

>>> 
Line 1 - Result of + is  25
Line 2 - Result of * is  250
Line 3 - Result of / is  25.0
Line 4 - Result of // is  2.0
Line 5 - Result of ** is  1024.0
Line 6 - Result of % is  4.0
Line 7 - Result of - is  -6.0
>>> 

Python Arithmetic Operators

Python Arithmetic operators :

Python provides some arithmetic operators which perform the task of arithmetic operations. Below are some arithmetic operators –

Consider the value of num1 = 10 and num2 = 5

OperatorExplanationExample
+It is used to perform addition of two numbers num1 + num2 will give 15
It is used to perform subtraction of two numbers num1 – num2 will give 5
*It is used to perform multiplication of two numbers num1 * num2 will give 50
/It is used to perform division of two numbers num1 / num2 will give 2
%It is used to perform modulo operator where num1 is divided by num2 and remainder will be returned num1 % num2 will give 0
**It is used to perform exponential calculation of two numbers num1 ** num2 will give 10 to the power 5
//It is used to perform floor division of two numbers 10//2 will give 5

Floor Division :

In the Python floor division, when a number is divided by another number then digits after the decimal point of result will be removed.

OperatorExplanation
10 // 3Result of the operation is 3 mathematically in case of integer division. Floor division also provide result = 3
10.0 // 3Result of the operation is 3.33 mathematically but using floor division result would be 3, as it removes digits after decimal point

Example:

#!/usr/bin/python

num1 = 10
num2 = 5
res = 0

res = num1 + num2
print ("Line 1 - Result of + is ", res)

res = num1 - num2
print ("Line 2 - Result of - is ", res)

res = num1 * num2
print ("Line 3 - Result of * is ", res)

res = num1 / num2
print ("Line 4 - Result of / is ", res)

res = num1 // num2
print ("Line 5 - Result of // is ", res)

res = num1 ** num2
print ("Line 6 - Result of ** is ", res)

res = num1 % num2
print ("Line 7 - Result of % is ", res)

Output :

>>> 
Line 1 - Result of + is  15
Line 2 - Result of - is  5
Line 3 - Result of * is  50
Line 4 - Result of / is  2.0
Line 5 - Result of // is  2
Line 6 - Result of ** is  100000
Line 7 - Result of % is  0
>>> 

No cases in switch case : C Programming

No cases in switch case

void main()
{
 int choice = 2 ;
 switch(choice)
  {
  }
}

Explanation :

Consider the above switch case example in C Programming. In this example, we have written the switch case with no cases in switch case

Re-commanded Article : Rules of using switch case | Invalid ways of switch case

No cases in switch case - c programming

We never write such kind of statement because it is not required at all while writing code in C but still syntactically no cases in switch case is allowed.

switch(choice)
  {
  }

In this case switch case would be executed but nothing will be printed on the screen

Eclipse Creating Java Class

Till now we have learnt about the following important topics –

In this chapter we will be learning how to create a Java class

Eclipse Creating Java Class

We can create the Java Class using the following 3 different ways –

  1. By clicking on the File menu and choosing New > class
  2. By right clicking anywhere in the Project Explorer and selecting New > class
  3. By clicking on the New button (Eclipse Creating Java Class - icon) in the Tool bar and selecting class

Steps for creating Java class

Right click on the package explorer in the Eclipse Workspace and then select the class option

Eclipse Creating Java Class

After selecting the class icon we need to fill following information that we have listed in the table –

Eclipse New class name window

FieldExplanation
Source/Folder NameProvide the correct source name
PackageProvide the appropriate package name
NameProvide the class name with first letter as capital letter
Method StubsIf you want to create the main method by default then just check the respective check box
CommentsIf you want to generate the default comment then select the check box.

After the creation of the class we can see how class is created in the eclipse –

Viewing class in eclipse

Eclipse Creating Java Package

Once we create a Java Project in Eclipse, we might want to create a java package in Eclipse IDE. It can be achieved using the three ways –

Eclipse Creating Java Package

We can create the Java Project using the following 3 different ways –

  1. By clicking on the File menu and choosing New > Package
  2. By right clicking anywhere in the Project Explorer and selecting New > Package
  3. By clicking on the New button (Select Java Package ) in the Tool bar and selecting Package

Steps to create Package

Right click on the package explorer in the Eclipse Workspace and then select the package option

Creating Java Package in Eclipse

Once you select the package option then you will be prompted with the below screen

Eclipse Naming Java Package

You need to name your Java package which should not contain the space or dot at the last. Otherwise it will provide you following error message – Invalid package name. A package name cannot start or end with a dot

Invalid Java Package Name

Once we create package then we can see it inside the package explorer like this –

Eclipse Viewing Package

Eclipse Creating Java Project

In this tutorial we will be learning how to create a sample Java project in the Eclipse IDE.

Eclipse Creating Java Project

We can create the Java Project using the following 3 different ways –

  1. By clicking on the File menu and choosing New > Java Project
  2. By right clicking anywhere in the Project Explorer and selecting New > Java Project
  3. By clicking on the New button (new project icon ) in the Tool bar and selecting Java Project

Steps to create project

Step 1 - Create new Java Project

Now when we select Java Project as option then we below window gets opened.

Step 2 - Name Java Project Eclipse

Give proper name to your Java Project. Project name should not contain space.

Step 3 - Provide Project Setting

Just keep these settings as it is and click on the next button to proceed further

Step 4 - Perspective

It would then prompt user with message saying that your project will be opened in the Java Perspective.

Step 5 - Java Project Created

After clicking on the finish button your project will be created in the Workspace.

Eclipse IDE Workspace

When we start the project then we need to open a folder where your code or project resides. Folder which is used for the development is called workspace

Eclipse IDE Workspace

Workspace of the Eclipse is nothing but the collection of the files arranged inside the defined directory structure. Workspace contains following resources –

  1. Projects
  2. Source/Configuration of any type of File
  3. Folders/directories

Workspace is arranged in hierarchical structure. Projects are at the top level of the hierarchy and inside them all the files and folders are listed

Eclipse Workspace Tree

You can see all the resources are arranged in the tree or hierarchical fashion.

Creating folder in Workspace

Now we are going to create a folder in the workspace which is used to store all the assets that we are using inside the project

Create folder in Eclipse Workspace

Now give proper name to folder in the Workspace. See below screenshot

Naming folder name

Now you will be able to see the folder created inside the workspace.

View created folder