DBMS

Friday, April 10, 2020

Introduction to Views

Views are the objects of the database which allows to access part of the entire logical model. Depending upon the requirement, access permission and authentication of the user, the views are created. Since, typically, views are actual relation stored in database i.e. views are typically not belong to the conceptual model. View allows to showcase only specific rows depending upon condition corresponding to specific attributes belonging to same or different tables

A view is defined using create view statement and uses one or more existing table.

The generic statement for creating view is as follows:

     create view view_name as query_expression

Here, we are taking an example of table t1 and creating a view v_t1 based on table single table t1.


We can see using show table command that view is listed with other existing tables.

Describe View


The logical schema of the newly created view using following command:

desc v_t1;       OR 

describe v_t1;

Drop View

The view can be permanently drop existing view definition by using following command:

drop view v_t1;

Insert Data through View

Whenever a user need to insert data through views so data will be updated in the original table (if certain condition satisfy). The condition is view must be insertable (will discuss later in detail).

Wednesday, October 2, 2019

Biwise Shifting Techniques and Data Conversion Formats

Arithmetic Shift Vs. Logical Shift

Arithmetic Shift operates on the data, it considers data as signed integer and does not shift the signed bit. (in both cases: either left or right shift)
In case of logical shift, sign of the data is not important, and data is shifted left of right without worring about the sign.

Impact

If during shift operation, overflow occurs then both arithmetic and logical shift may produce different results i.e. arithmetic shift do not allow overflow but the logical shift allows to occur.
Example
Before shift data is
10101001
After 1 bit logical left shift
01010010    #sign changed
After 1 bit arithmetic left shift
11010010    #sign unchanged

Rotation or Cyclic Shift

In the cylic shift, each bit is rotated (depending upon left or right rotation) without loosing the bits. In this process each bit can come at the sign bit location (LSB) which helps to identify the sign of the data.
Every shift operation is performed by ALU with the help of the transfer instructions.

Conversion into Binary Coded Decimal (BCD) Format

In BCD Conversion, each decimal digit is converted into four bits. It is send in Packed Decimal or Unpacked Decimal Format. The digit 0 is converted into 0000, 1 as 0001, ...,9 is represented as 1001. BCD convertion takes equal to or more number of bits than a normal binary conversion. In Packed decimal 8 bits are transferred with bad at 4 LSBs and few unimportant bits at MSBs, whereas in packed decimal, two numbers are simultaneously managed at 4 LSBs and 4 MSBs.

Conversion into International Reference Alphabet (IRA) Format

In IRA conversion, each decimal number is represented in four bits considering 011 as prefix. so 0 is represented as 0110000, and 9 is represented as 0111001.

Conversion into American Standard Code for Information Interchange (ASCII) Format

For ASCII conversion, each character is given 7 bit code. The most significant bit is filled with o or 1 depending upon the type of parity (even or odd parity) maintained for data transfer.

Conversion into Extended Binary Coded Decimal Interchange Code (EBCDIC) Format

Similar to IRA coding, EBCDIC coding also converts each and every bit in four bits. The only difference is, it use 1111 as prefix, i.e. 0 is represented as 11110000 and 9 is represented as 11111001.

Tuesday, October 1, 2019

Operations on List Containers in Python

List 

As discussed in previous blog, the list is container which is mutable i.e. the elements in the list can be modified, added or deleted, etc.
Let the given list is 
L = [1, 4, "Arjun"]
print(L)
Output>>>
[1, 4, 'Arjun']
To add element in the list following:
L = L.append("Karna")
print(L)
Output>>>
[1, 4, 'Arjun', 'karna']
Typically, element is added in the last. To insert element at any specific index number, do following:
L=[1, 4, 'Arjun', 'Karna']
L.insert(2,'Dronacharya')
print(L)
Output>>>
[1, 4, 'Dronachayra', 'Arjun', 'Karna']
To delete specific element from the list, do following:
L.remove("Arjun")
print(L)
Output>>>
[1, 4, 'Karna']
To remove last element from of the list, do following:
L=[1, 4, 'Arjun', 'Karna']
L.pop()
print(L)
Output>>>
[1, 4, 'Arjun']
To clear all the element from the list, do following:
L=[1, 4, 'Arjun', 'Karna']
L.clear()
Output>>>

[]
To delete the whole list including container, do following:
L=[1,4,'Arjun','Karna']
del(L)
print(L) #get error as L is not existing now. 💭
To copy content of one list to another list
L1 = [1,4,"Arjun", "Karna"]
print(L1)
L2 = L1.copy()
print(L2)
L1.append("Dronacharya")
print(L1)
print(L2)
Output>>>
[1,4, "Arjun", "Karna"] [1,4, "Arjun", "Karna"] [1,4, "Arjun", "Karna", "Dronacharya"] [1,4, "Arjun", "Karna"]
If we use L2=L1, L2 will create only reference of L1 (nothing else) and all the changes made in L1 will be reflected in L2 i.e. L2 will be dependent on L1 that we don't require everytime.
L1=[1,4, "Arjun", "Karna"]
L2=list1 L1.append("Dronacharya") print(L1) print(L2)
Output>>>
[1,4, "Arjun", "Karna", "Dronacharya"]
[1,4, "Arjun", "Karna", "Dronacharya"]
To concatenate two strings
L1 = ["Ram", "Shyam", "Mohan"]
L2 = [10, 20, 30]
L3 = L1 + L2
print(L3)
Output>>>
['Ram', 'Shyam', 'Mohan', 10, 20, 30]
or, we can do concatenation of two lists using for loop also, as follows:
L1 = ["Ram", "Shyam", "Mohan"]
L2 = [10, 20, 30]
for index in L2:
    L1.append(index)
print(L1)
Output>>>
['Ram', 'Shyam', 'Mohan', 10, 20, 30]
or, we can do the concatenation two lists using extend funciton:
L1 = ["Ram", "Shyam", "Mohan"]
L2 = [10, 20, 30]
L1.extend(L2)
print(L1) 
Output>>>
['Ram', 'Shyam', 'Mohan', 10, 20, 30]
To sort the elements of the given list, do following:
L1 = ["Ram", "Shyam", "Mohan"]
L1.sort()

print(L1)
Output>>>
['Mohan', 'Ram', 'Shyam']
To count total number of items of similar type, do following:
L1 = ["Ram", "Shyam" , "Mohan", 'Ram']
print(L1.count("Ram"))
Output>>>
2
To count total number of items in list:
L1 = ["Ram", "Shyam" , "Mohan", 'Ram']
print(len(L1))
Output>>>
4
To count length of each and every item in list:
L1 = ["Ram", "Shyam" , "Mohan", 'Ram']
for index in L1:

    print(len(index))
Output>>>
3 5 5 3

Sunday, September 29, 2019

English Grammar Tips

English Grammar

In English, we make many common mistakes which must be avoided everytime. Many times, we write grammatically correct but depending upon whether its formal or informal place to write (what kind of literature it is), your correct grammar may also be wrong.

Wrong Vs. Right   (Wrong / Right)         

  • Very Crowded / Bustling 
  • Very Sad / Sorrowful
  • Very Funny / Hilarious
  • Very Serious / Grave
  • Very Rich / Wealthy
  • Very poor / Destitute
  • Very Easy / Effortless
  • Very Slow / Sluggish
  • Very Quick / Rapid
  • Very Stupid / Idiot
  • Very Intelligent / Genius
  • Very Simple / Basic
  • Very Shy / Timid
  • Very Open / Transparent
  • Very Quite / Hushed
  • Very Sharp / Keen
  • Very Scary / Chilling
  • Very Painful / Excruciating
  • Very Pale / Ashen
  • Very Old / Ancient or Antique
  • Very Perfect / Flawless
  • Very Scarred / Petrified
  • Very Shiny / Gleaming
  • Very Short / Brief
  • Very Long / Extensive
  • Very Noisy / Deafening
  • Very Clear / Obvious
  • Very Rainy / Pouring

Informal Vs. Formal  (Novel / Text Book) 

  • Thanks a lot / I appreciate your assistance
  • Reminder / I would like to remind you that
  • Heard from him lately? / Have you heard from him lately?
  • I think / In my opinion that
  • Bacause / In the light of the fact that
  • Worried about / Concerned about
  • As soon as you can / At your earliest convenience
  • Say hello to / Give my regards to
  • Nice to meet you / It is a pleasure to meet you
  • At any rate / In any case
  • Catch up / See you later
  • Hit me up / Write me
  • It's on me / I pay for it
  • Not in my books / Disagree
  • Take it easy / By for now
  • Okay by me / It's fine
  • What;s up buddy? / How are you?
  • Play it by ear / go with the flow
  • Sleep on it / Think about it
  • Beats me / I have no idea
  • Give me a break / Leave me alone
  • Not my cup of tea / Not interested
  • Its a piece of cake / It is easy to do
  • What's up or hows life? / How do you do.   
  • Generally / Typically
  • Ultimately / Eventually
  • Maybe / Perhaps
  • But / However   
  • So / Therefore
  • Looking for / Searching
  • This is why / Therefore
  • Given / Provided
  • In exchange of / In lieu of
  • Buy / Purchase
  • Choose / Select
  • Need / Requirement

Common Mistakes (Wrong / Right) 

  • Who is in the phone? / Who is on the phone?
  • I deeply regret for my mistakes. / I deeply regret my mistakes.
  • Ram is so different than his brother. / Ram is so different from his brother.
  • She is afraid from dark. / She is afraid of dark.
  • Sun rises from the east. / Sun rises in the East.
  • Keep the left please. / Keep to the left, please.
  • Ram is absent from friday. / Ram is absent since friday.
  • The high tea consist from coffee and tea. / The high tea consist of coffee and tea.
  • He insisted to carry his own bag. / He insisted on carrying his own bag.
  • Vegetables are eatable. or Vegetables are eatible. / Vegetables are edible.
  • I prefer tea than coffee. / I prefer tea to coffee.

Saturday, September 28, 2019

Python Data Types (Basic Operations Part-1)


There are few basic standard data types
a) Number, b) String.

Number

  • The number data type stores numerical values. Whenever any number is assigned to any variable, python creates a Number object.
x  =4, y = 7.  Here, x and y both are number objects.
  • Python supports 4 type of numeric value.
  1.  int (any integer like 10, 20, etc.)
  2. long (integer having larger values like: 2320320424L) 
  3. float (any floating point value which requires more precision that integer or larger than integer). Ex - 10.9, - 5.4, or any large value.
  4. complex (complex numbers like 2 + 3j).
  • If we want to check data type of any variable we can do it with the help of type function.
a = 20
b = 3.5
c = "Hello Python"
print(type(a))
print(type(b))
print(type(c))
Output >>>
<type, 'int'>
<type, 'float'>
<type, 'str'>

String

  • The string data type stores the sequence of characters in the sinlge or double or triple quotation signs. Following are the valid assignment of string to a variable.
a = 'Brij' or
b = "Krishna" or
c = '''Arohi and Nupur'''
  • If two strings are needed to be added this operation is known as concatenation of two strings. Concatenation operation is performed with the + operator. This + operator arrives in between both strings written in single, double or triple quote.
print(a+b+c)
>>>BrijKrishnaArohi and Nupur
d = "Brij "' + "Krishna " + "Arohi and Nupur"
e = 'Brij ' + "Krishna " + '''Arohi and Nupur'''
print (d)
print (e)
>>>Brij Krishna Arohi and Nupur
>>>Brij Krishna Arohi and Nupur
  • If the same string has to be repeated multiple number of times, there is provision of * operator. Depending upon how many times we need to print the same string, we can mupltiply by that number.
a = "Ram " * 5
print(a)
>>> Ram Ram Ram Ram Ram
  • There is a provision of slicing the content of string. Many times we want only limited part of any string which can be obtained by slicing operator [ : ]. It takes two parameters a[x:y] to decide which part of the string is going to be included, x = starting index, y = end + 1 index, where index starts from 0.
a = "Hello Python"
print(a)
>>> Hello Python
print(a[:]
>>>Hello Python
print(a[2:8])
>>>llo Py
  • Index starts from 0 to string length - 1 (+ve number) or the same indexing can be done from last to first in which indexing starts from last charcter treating it as -1 and -2, -3, ...towards first character of string.
a = "Hello Python"
print(a[-12:-1])
>>>Hello Pytho
print([-12:-2])
>>>Hello Pyth
  • This simply means when we start couning from starting so couning starts from 0 and increases towards next characters till the end of string. On the other hand, if counting of character in string starts from end then its starts from -1 and decreases towards start of the string.
Index    :    0   1   2   3   4   5   6   7
String        H   E   L    L  O   S   I    R
or
Index    :   -8  -7  -6  -5  -4  -3  -2  -1
String        H   E    L   L   O   S    I   R
  • The concatenation  operation + and repetition operation * are applicable not only for string but also for the list elements, tuple and dictionoary elements too.
list1 = [1, 3, 5, 7]
list2 = [2, 4, 5, 8]
print(list1+list2)
>>>[1, 3, 5, 7, 2, 4, 5, 8]
print(list1*2)

>>>[1, 3, 5, 7, 1, 3, 5, 7]

Friday, September 20, 2019

Python Basics


Python Data Types and Collections

  • Typically, in every high level programming language, data is stored in variables. In the python variables store data of various data types. 
  • The variable name must start from underscore ( _ ), digit (0 - 9), character (a - z and/or A - Z) nothing else i.e no special character is allowed for variable name.
  • Python majorly supports data of int, float, string and complex number data types.
  • As I told earlier, data of above data types can be stored in the variables. However, when large amount of data have to be saved in variables then it becomes tedious. To make process easy there are collection mechanism provide for it and these are known as containers. Majorly, List, Tuple, Dictionary and Set are the containers. 
  • Before moving further, I would like to make it very clear that out of these four containers, first two containers i.e. a) list and b) tuple, supports data of various data types i.e same list may have data of multiple data types simultaneously. Similarly for tuples too. Wow!! its great. Further, all these containers can contain any finite number of items (not infinite). 😁
  • Now you would be thinking that what is the difference between list and tuple. Yeah I know...The difference is this...List is mutable but tuple is not. Means, once the container is created as tuple means tuple container is declared, it can't be modified further but but if list container has been created it can be modified any number of times. Very Simple..!! 
  • Now the question comes that how to declare a list. In list all elements are declared with in [ ] and multiple items are seperated by comma (,). Strings are writtern within double quotes (" ")  or single quotes ( '  ' ). Suppose you want to declare a list of integer items : 

L = [10, 4, 2, 7, 5]

if you want to declare list of strings or float items, do this:

L = ['Brij', 'Krishna', 'Radha', 'Meera']

L = ["Brij", "Krishna", "Radha", "Meera"]

L = ['Brij', "Krishna", 'Radha', 'Meera']

If you want to declare list of items of mix data types, do this:

L = ["Brij", "30", 20, 10.5] 
In all above cases output will be list with all its elements.
  • Similarly, if we want to declare a tuple then please note that all elements are declared with in ( ) and all other things are very similar to that of tuple i.e. multiple items are seperated by comma ( , ). Strings are writtern within double quotes (" ")  or single quotes ( '  ' ). Suppose you want to declare a tuple of integer items : 

T = (10, 4, 2, 7, 5)

if you want to declare tuple of strings or float items, do this:

T = ('Brij', 'Krishna', 'Radha', 'Meera')

T = ("Brij", "Krishna", "Radha", "Meera")

T = ('Brij', "Krishna", 'Radha', 'Meera')

If you want to declare tuple of items of mix data types, do this:

T = ("Brij", "30", 20, 10.5)

In all above cases output will be tuple with all its elements.
  • Now little bit about third container i.e Dictionary. Dictionary is actually works on the principle of key-value pair. i.e. each and every item is actually key-value pair and these items will be written with in curly braces { }. 
  • Further all the items (key-value pair) will be seperated by comma and with each element key and values are seperated by colen ( : ). 
  • The beauty of keys is; each and every key is unique with the dictionary and all these values may or may not be unique (generally not).
  • The key and values may of any data type, or even may be container too. Wow!! Are you getting what I am saying...See these examples.

D={1:4, 3:7, 2: 9}

D={1:4, 3:7, 2: [9, 4]}

D={1:4, 3:(3,5), 2: [9, 4]}

D={1:{5:8, 3:2, 7:1}, 3:(3,5), 2: [9, 4]}

D={'c':6, 'a':1, 'b':3}

In all above cases, output will be dictionary with all its elements in the acsending order of keys.

  • All above are valid formats.
  • In next lecture we will discuss about operations on elements of these containers.

Saturday, February 20, 2010

Quotations



  • I heared...I forget, I saw...I remember, I did...I understand.
  • The best morale sanction is that of the conscience and the worst is the fear of punishment.
  • I learn by going where I have to go.
  • I was born to win, but I kept loosing, because I never planned and prepared for winning.
  • Good is the worst enemy of the Best.
  • I always like walking in the rain, so on one can see my tears. - Charlie Chaplin
  • I have many problems in my life, but my lips don't know that, they always smile. - Charlie Chaplin
  • The day without laughter is a day wasted. - Charlie Chaplin
  • Perfection is an illusion based on our own Perception.
  • Perfection is not a destination, it's a never-ending journey. - Jim Vouchers
  • Perceiving imperfection in perfection is preferable perspective to achieve perfection. - Dr. Brij Bhari Dubey

GITA

Chapter 18: Conclusion-The Perfection of Renunciation

Text - 48
saha-jam karma kaunteya
sa-dosam api na tyajet
sarvarambha hi dosena
dhumenagnir ivavrtah
Every endeavor is covered by some sort of fault, just as fire is covered by smoke. Therefore one should not give up the work which is born of his nature, O son of Kunti, even if such work is full of fault.
  • etc.