Wednesday, May 6, 2015

Joins In DBMS




(part 1)

There are several types of joins used in relational algebra to get results from two or more tables.


Theta join

The theta join operation defines a relation that contains tuples satisfying the predicate from the Cartesian product of R and S. Theta can be <,>,<=,>=,=,≠
Example 





Here output will be the tuples that have same “sid” in both tables (Cartesian product).

R
sid
sname
rating
age
22
Dustin
7
45.0
31
Lubber
8
55.5
58
Rusty
10
35.0

S
sid
bid
day
22
101
7/10
31
103
8/02

Here from S and R Cartesian product is (RxS) as follows.

RxS
sid
sname
rating
age
sid
bid
day
22
Dustin
7
45.0
22
101
7/10
22
Dustin
7
45.0
58
103
8/02
31
Lubber
8
55.5
22
101
7/10
31
Lubber
8
55.5
58
103
8/02
58
Rusty
10
35.0
22
101
7/10
58
Rusty
10
35.0
58
103
8/02

But from above theta join we can have only tuples that have same “sid” in two “sid” fields in RxS

sid
sname
rating
age
sid
bid
day
22
Dustin
7
45.0
22
101
7/10
22
Dustin
7
45.0
58
103
8/02
31
Lubber
8
55.5
22
101
7/10
31
Lubber
8
55.5
58
103
8/02
58
Rusty
10
35.0
22
101
7/10
58
Rusty
10
35.0
58
103
8/02

Highlighted tuples are the result of theta join.

Equi join

This is also a particular type of theta join. But it always deals with equal operator.
 From theta join : 


This can be expressed using equi join as



Natural join

The natural join is an equi join of the two relations R and S over all common attributes. One occurrence of each common attribute is dominated from the result.




In equi join we has below results.



Here we have two “sid” columns. But in natural join we have only one column from duplicated columns.
 

  sid
sname
rating
age
bid
day
22
Dustin
7
45.0
101
7/10
58
Rusty
10
35.0
103
8/02

To be continued...

Sunday, May 3, 2015

My Note – BETA


Description :


This is a notepad program developed by PC-Cabinet.
With this program you can write text files, HTML files, Java files, CSS ,Javascript ,Batch files and many more.


As this is BETA version errors and bugs are not totally corrected.


We will release our stable version shortly.


ClickHere to download My Note-Beta Version



ClickHere to download My Note-Beta Version zip file

Friday, May 1, 2015

How use message boxes with C# application

How to use message boxes with C# application

Most programs use message boxes to give messages to user. When we develop a software we have to deal with message boxes. Message boxes can use to give messages,confirm messages, warning messages , error messages and meany more. Here we are going to discuss about message boxes in C# applications.

Now start with a new project. Name it as you like. Here I have named it as “msgtest”.But you can name it as you like or you can keep it unchanged with it's default name “WindowsFormsApplication1”.



Now you have a form on your screen.

Now let's code a simple message.

Double click on your form and now you are at your code window.

Now type these codes.

        MessageBox.Show(“This is my first message”);





Now press “F5” or click on “start debugging” in debug menu.
Now when your form loads windows will show a message box with your message and with a “OK” button.


Now try this with a button.

Get a button to the form and change it's text property as you like.
Now double click on your button and type this code.

        MessageBox.Show(“Button clicked”, “My message”);

Now when you run your form and click on your button message box will appear with a title “My message”. This is the text that we used within double quotation marks after the comma.

Now it's time to study about this code.

The general form of a message box is 
        MessageBox.Show(“Your Message”, “Message title”);

But here you can't change message box buttons and message box icon.
So there is another format.
MessageBox.Show(“Your Message”, “Message title”, messagebox_buttons, messagebox_icon);

Now let's try this in an button. Get a new button to the form and change it's text property to “Click Here” .Now double click it and you are at your code window. Now try this code.

MessageBox.Show(“Do you want to save changes to Document1?”, “Message1”, MessageBoxButtons.YesNoCancel, MessageBoxIcon. Exclamation);

Now run this using “F5” key or clicking “start debugging” in debug menu.
If you clicked on second button you can see a message box with a title “Message1” and buttons “ Yes” , “No”, “Cancel”.
Here you can see an exclamation mark as message box icon. Now it will remember you the message box that will appear when we going to close a Microsoft Word document without saving changes.(Check it your self)

Like above example try to create message boxes that commonly used in programs to get an experience about message boxes.

In C# you can use icons like Question,information,exclamation,error, warning,Asterisk,hand none and stop. These icons are mostly used by your Operating System and many applications.

You can use buttons like YesNoCancel, YesNo, OK, OkCancel, RetryCancel, and AbortRetryIgnore.

Now let's try to code buttons in a message box.
Open a new project or clear your current project.
In the form get a new button and change it's text property to “msg_test” or whatever you like.
Now get a text box and change it's text property as “Please click on the button”.
Now double click on the button and code these codes.

switch(MessageBox.Show(“Do you want to check messages ?”, “Message”,MessageBoxButtons.YesNoCancel,MessageBoxIcon.Question)){

        case DialogResult.Yes :
             textBox1.Text(“You clicked on Yes”);
             break;
       case DialogResult.No:
             textBox1.Text(“You clicked on No”);
             break;
      default :
             textBox1.Text(“You clicked on Cancel”);
             break;
  }




Here I used a “switch case” statement , but you can also use if else statements.

Now if you run this and click on your button then a message box will appear and text in your text box will change correspond to the Yes, No,or Cancel button you clicked.


Now try with different buttons and different icons.



Thank you! 
--------------------------------------------------------------

Recommended by author

How to use sounds in a C# application

INTRODUCTION TO PYTHON

Creating your first HTML document