Sunday, December 12, 2010

Essentials of Mysql

Essentials of MYSQL

MySQL is a relational database management system it runs as a server providing multi-user access to a number of databases. MySQL is officially pronounced mai es que el ("My S-Q-L"), but is often also pronounced mai sequel  ("My Sequel"). It is named after developer Michael Widenius' daughter, My. The SQL phrase stands for Structured Query Language.


Uses of Mysql

   It is lightweight than other databases
   It can perform more flexibility depend on their requirements
  We can configure the settings mysql to our own specifications

Installation of mysql

                     Three things we have to do install mysql

                       Install mysql-server,mysql-client,mysql-lib

   
MYSQL ARCHITECTURE
                                   




Thursday, December 9, 2010

Practicing Ruby simple Exercise

//today i wrote the sample code of shopping details in ruby

sum=0
for i in 1..2
puts "enter the item name"
name=gets
puts "enter the no.of quantity"
qty=gets.to_i
puts "enter the price details $"
price=gets.to_i
total=qty*price

x=puts "the total price for the #{name} is #{price} and total billed today is #{total} thanks for nice day"
end
puts x



///sample code for railway reservation counter

class RailwayReservation



def enquiry
  puts "Welcome to the chennai railway station"
  puts "enter ur pnr number"
  @x=gets.chomp
 
end

def reservation
   puts "enter the source and destination"
   @y=gets.chomp
   puts "enter the number of persons to travel"
   @z=gets.chomp.to_i
end



def calculation
 
puts "your Pnr number is #{@x}"
 @total= @z * 250
puts "the total fare for #{@z} persons is #{@total}"
end



obj =RailwayReservation.new()

obj.enquiry
obj.reservation
obj.calculation
end

Wednesday, December 1, 2010

Learning Basic Mysql from scratch

today i learning the basics of mysql

just i creating the database

to creating the database in mysql

create database slashprog;


to see the databases after creating the database


show databases;
later we using this command:---  use slashprog;
create a table

like wise we can create "n" number of maximum tables in a database

to see what are all the tables inside our database

syntax:- show tables;

syntax:--- create table (tablename)

create  table students(name varchar(32),age int,address varchar(32));

insert values in table

syntax:--- insert into (tablename) values(xxx,25,yyyy);


to see the table structure command is

desc (tablename)

To see all the values in table

select * from (tablename)

To see all the values in the table


select * from students;
+----------+------+--------+
| name     | age  | salary |
+----------+------+--------+
| kiran    |   25 |  25000 |
| sathia   |   26 |  10000 |
| john     |   28 |  14545 |
| jenefier |   26 |  12454 |
| smith    |   29 |  14564 |
| sachin   |   30 |  12456 |
+----------+------+--------+



select only names to see the syntax below as follows :---

select name from students;
+----------+
| name     |
+----------+
| kiran    |
| sathia   |
| john     |
| jenefier |
| smith    |
| sachin   |
+----------+

 to see the ages of above 26 in the database the command

select age from students where age >26;
+------+
| age  |
+------+
|   28 |
|   29 |
|   30 |
+------+

to show the maximum age of of the students

select MAX(age) from students;
+----------+
| MAX(age) |
+----------+
|       30 |
+----------+


to sumup the fields of the salary of the table 
select SUM(salary) from students;
+-------------+
| SUM(salary) |
+-------------+
|       89019 |
+-------------+

to see the only few rows in the tables we can set limit to them

select name,age,salary from students LIMIT 3;
+--------+------+--------+
| name   | age  | salary |
+--------+------+--------+
| kiran  |   25 |  25000 |
| sathia |   26 |  10000 |
| john   |   28 |  14545 |
+--------+------+--------+

to know the average of the ages

select AVG(age) from students;
+----------+
| AVG(age) |
+----------+
|  27.3333 |
+----------+
to count the number of entries in mysql

elect COUNT(age) from students;
+------------+
| COUNT(age) |
+------------+
|          6 |
+------------+

to see the version of the mysql

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.1.41    |
+-----------+

to see the time and date

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2010-12-02 14:37:02 |
+---------------------+
1 row in set (0.00 sec)




Update command in mysql
update students SET salary=5000,age=26 WHERE name="smith";
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

mysql> select * from students;
+----------+------+--------+
| name     | age  | salary |
+----------+------+--------+
| kiran    |   25 |  25000 |
| sathia   |   26 |  10000 |
| john     |   28 |  14545 |
| jenefier |   26 |  12454 |
| smith    |   26 |   5000 |
| sachin   |   30 |  12456 |
+----------+------+--------+

mysql> delete from students where name="smith";
Query OK, 1 row affected (0.00 sec)

mysql> select * from students;
+----------+------+--------+
| name     | age  | salary |
+----------+------+--------+
| kiran    |   25 |  25000 |
| sathia   |   26 |  10000 |
| john     |   28 |  14545 |
| jenefier |   26 |  12454 |
| sachin   |   30 |  12456 |
+----------+------+--------+

Monday, November 29, 2010

Ruby

Ruby

-----------------------------
to check the path of the ruby

which ruby

/usr/bin/ruby
-------------------------------
If you executing ruby from shell script

go to vi mode ......and then type the programme and save it in .rb  The file name should have extension of .rb and save it any where in !

vi trial.rb

#!/usr/bin/ruby

./trial.rb

--------------------------------
If you executing ruby from normal mode

vi trial.rb (assume that we save in desktop or file system )

ruby trial.rb (to compile the ruby code)
---------------------------------
comments in ruby    

single line comment

#This is the single line comment in ruby

multiple line comment

==begin

to start with multiple line comment we have to start ==begin from beggining and ==end from ending

==end
----------------------------------

declaring variables in ruby

a=10
b=10
c=10

parallel way of assigning variables in ruby

a,b,c,d=10,20,30,45
------------------------------------
to know the what type of variables in ruby

a=25
b=45.0
c="welcome"
a.class()
b.class()
c.class()

to check whether it is integer/float/string

a.kind_of? Integer
b.kind_of? String
----------------------------------------
converting variables values

    y=20
         y.to_s  #it converts to string
         y.to_f  #it converts to float

to convert the integer binary
              y.to_s(2)   #converts to binary base 2
              y.to_s(8)   #converts to base 8 (octal)
              y.to_s(16)  #converts to base 16(Hexa decimal)

--------------------------------
variable scope in ruby

ruby has 5 types of variable scope in ruby

$ --global variable
@-- instance variable
a-z--local variable
A-Z-- constant variable
@@---class variable

to know the type of the variable in ruby

defined? ($x or @x or x or @@x)

Friday, November 26, 2010

Ruby with mysql

today
thiyagu
sir told the difference between ruby using ordinary mysql
and Ruby using ORM(object Relational Mapping)

create a database called student

Ruby code to access the table rubyists (ORM using Ruby)

i wondered here sql function not using anywhere in this programme

Let's write a Ruby program and name it as db_connect.rb

    require 'rubygems' 
    require 'active_record' 
    ActiveRecord::Base.establish_connection( 
       :adapter => "mysql", 
    :host => "localhost", 
    :database => "students" 
    
     
    class Rubyist < ActiveRecord::Base 
     end 


     Rubyist.create(:name => 'Luc Juggery', :city => "Nashville, Tenessee") 
     Rubyist.create(:name => 'Sunil Kelkar', :city => "Pune, India") 
     Rubyist.create(:name => 'Adam Smith', :city => "San Fransisco, USA") 

Then sir also told the ordinary way of connecting this  programme through mysql

SLASHPROG TECHNOLOGIES

//started project in slashprog technologies //


monday---------------our sir introduces what are all the modules can be coming in our website

                     we started our ideas about our website details

                     who we are ...what we doing for website

                     in three ways we focus on our site

                      1) trainers side

                      2) client side

                      3) vendors side


tuesday-----------------we discussed what technology we going to be use a little argument whether we use jquery and Dojo

                        finally we decided with Dojo ...its an powerful opensource tool to develop javascript ajax based
                         
                         applications Dojo advantage is it is compatible with all modern browsers it even work if javascript

                        not enabled in client side browsers...as a developer we knowing of just html and javascript is enough
                      
                         not to know new language ...

wednesday -------------
                        Our team members are 

                                            Rajeswari
                                            Yogesh kannan
                                            rakesh
                                            suresh
                                            Rama chandran
                                            and me

we started learning little about ..Dojo just to create a button and checkbox .....we need to install Dojo

and extract zip/tar file and untar it .....we get the files as dojo,digit,dojox,util  these 4 files we save it in

js files so the path will be like this

under that js/digit
           js/dojo
           js/dojox
           js/util


writing an application  is easy its simple and straight forward ......




just load the dojo library in javascript


-------------------------------------------------------------------------------------

Thursday

we go through and play around some snippets of code in Dojo ..its fun and interesting we and our team members create some small small applications integrate and

finally created a login page and registration page for trainers module ..

we included the library stackcontainer in dojo to get the diaogue box and we created nearly 6 steps to register the trainers form

------------
Friday

our Sir gave introduction about UI flow diagram we discusses what are all the tools to implement whether code ignitor or CakePHP !

sir said how to play with www.960gs.com

and www.balsamiq.com

 www.oswd.org

we discussed how the home page of our website look like the features were we include and disable we discussed


-------------------

saturday

saturday sir told what is mysql and how we  connect mysql to php and how to create simple database and

to start mysql

just type mysql; it will start mysql in any

------------------------------------------------------



 



//****Trainers Home Page ***//


1) client requirements matching his skill

2) calendar

3) Update Profile

4)(client/vendor rate )--confidential

5) visitors

6) news ---< 1) location
             2) whether

7)Training Statistics

8) Last minute update

9) Payment History *(Only trainer can view )

10)Share his experience

11)Articles/blog

12)How to colloborate with other trainers ?

13) Approve Client request ---------< 1) through vendor
                                      2) Direct Client

14) Interact with Client/Vendor

              ----> Invoice
              ----> Training Prerequisites/resources
              ----> Feedback

Today we learning some basic exercises in ruby

#programme to find vowels in a file

vowels =%w[a e i o u]
count =0
open("a.txt","r").each do |line|
line.split(//).each do |character|
if vowels.include?character
count +=1
end
  end
end
print "no of words #{count}"
------------------------------------------------------------

26/11/2010
[Friday]


Today i learning ruby myself practicing small exercises like how to declaring an array in ruby 


x=["john","smith","joe","adam"]
x.each{ |i| puts i }
--------------------------------------------

 pop it deletes the last element in array

x=["john","smith","joe","adam"]
x.pop
-----------------------------------------
 to insert the elements from the beginning of the array


x=["array","range","rahul","sonia"]
x.pop
x.unshift("nickson")
puts x

---------------------------------------------
push to  insert the elements in the end of the array


x=["array","range","rahul","sonia"]
x.push("nickson")
puts x
------------------

Deletes the first element of the array

x=["array","range","rahul","sonia"]
x.shift()
puts x