Source One Educational Society
   
Home | JDBC | Advanced Java | Java Interview Questions | J2EE | Java FAQs | J2ME | Jobs | Java Examples | News | Jobs | Fun SMS
Java Tutorial
o

JDBC

o JDBC Architecture
o JDBC Driver and Its Type
o JDBC Versions
o Difference between JDBC 3.0 & JDBC 4.0
o Relational Database Concepts
o Important JDBC Concepts
o

Introduction to java.sql package

o Driver Manager Class
o Understanding Data Source
o Understanding Connection Object
JDBC EXAMPLE WITH MYSQL
o Mapping MySQL Data Types in Java
   
   
 
 

Relational Database Concepts

   

An important part of every business is to keep records. We need to keep records of our customers, the employees of our company, the emails etc. To keep all the data indivually is quite difficult and hectic job, because whenever if we need the record of a particular customer or an employee we need to search manually. It takes lot of time and still not reliable. Here comes the concept of databases.

 
What is database?
 
A database is an organized collection of information. A simple example of a database are like your telephone directory, recipe book etc.
A Relational model is the basis for any relational database management system (RDBMS). A relational model has mainly three components:
 
  1. A collection of objects or relations,.
  2. Operators that act on the objects or relations.
  3. Data integrity methods.

To design a database we need three things:

  1. Table
  2. Rows
  3. Columns

A table is one of the most important ingredient to design the database. It is also known as a relation, is a two dimensional structure used to hold related information. A database consists of one or more tables.

A table contains rows : Rows is a collection of instance of one thing, such as the information of one employee.

A table contains the columns: Columns contains all the information of a single type. Each column in a table is a category of information referred to as a field.

One item of data, such as single phone number of a person is called as a Data Value.

 
ACID Properties:
ACID properties are one of the important concept for databases. ACID stands for Atomicity, Consistency, Isolation, and Durability. These properties of a DBMS allow safe sharing of data. Without these properties the inaccuracy in the data will be huge. With the help of the ACID properties the accuracy can be maintained.
 
Normalization:
Normalization is a design technique which helps the to design the relational databases. Normalization is essentially a two step process that puts data into tabular form by removing redundant data from the relational tables. A basic goal of normalization is to create a set of relational tables that are free of redundant data and the data should be consistent. Normalization has been divided into following forms.
 
  1. First Normal Form: A relational table, by definition are in first normal form. All values of the columns are atomic. It means that it contains no repeating values
  2. A relationl table is in second normal form if it is in 1NF and every non- key column is fully dependent upon the primary key.
  3. A relational table is in third normal form (3NF) if it is already in 2NF and every non- key column is non transitively dependent upon its primary key. The advantage of having table in 3NF is that it eliminates redundant data which in turn saves space and reduces manipulation anomalies.
 
 
Understanding Common SQL statements
 
The commonly used SQL statements are:
  1. Select
  2.  Insert
  3. Update
  4. Delete
 

SQL Select statement:

 

The SELECT statement is used to select data from a table.

Syntax: Select column_names FROM table_name;

 

The result from a SQL query is stored in a resultset. The SELECT statement has mainly three clauses.

  1. Select
  2. From
  3. Where

The Select specifies the table columns that are retrieved. The From clause tells from where the tables has been accessed. The Where clause specifies which tables are used. The Where clause is optional, if not used then all the table rows will be selected.

We can see that we have used semicolon at the end of the select statement. It is used to separate each SQL statement in database systems which helps us to execute more than one SQL statement in the same call to the server.

SQL INSERT Statement:

This statement allows you to insert a single or multiple records into the database. We can specify the name of the column in which we want to insert the data.

 

Syntax: Insert into table_name values (value1, value2..);

The Insert statement has mainly three clauses.

  1. Insert: It specifies which table column has to be inserted in the table.
  2. Into : It tells in which the data will be stored.
  3. Values: In this we insert the values we have to insert.

We can also specify the columns for which we want to insert data.

 

The UPDATE Statement:

The Update statement is used to modify the data in the table. Whenever we want to update or delete a row then we use the Update statement.

The syntax is :

UPDATE table_name Set colunm_name = new_value WHERE column_name = some_name;

The Update statement has mainly three clauses.

  1. UPDATE: It specifies which table column has to be updated.
  2. Set: It sets the column in which the data has to be updated.
  3. Where: It tells which tables are used.
 

SQL DELETE Statement:

This delete statement is used to delete rows in a table.

Systax:

DELETE FROM table_name WHERE column_name = some_name;
The Delete statement has following clauses.

  • Delete: It specifies which table column has to be deleted.
  • From: It tells from where the Table has been accessed.
  • Where: It tells which tables are used.
 
 
 
 
 
 
 
Home  |  Aboutus  |  Post Your Content  |  Tell a Friend  |  Contact us  |  Sitemap
© 2009 365edu. All Rights Reserved. Site by 365edu. Best view in 1024x768 resolution.