Showing posts with label Databases. Show all posts
Showing posts with label Databases. Show all posts

Records Management

Natural disasters, litigation, and computer failure are a few of the reasons to have records storage procedures done professionally to prevent mistakes. A records management service organizes, classifies, archives, preserves, and purges physical files and electronic information. A records management service stores documents and data safely, allows for their access, provides specialized storage, and can destroy them properly when they are no longer needed.

If a company stores and manages their records in house, it is expensive and not secure for information, and mistakes can be made. Paper records, including highly confidential documents, need to be managed, organized, and stored securely off site. Some businesses choose a self storage facility for off site storage. This is not a secure place for company history! A records management service uses alarm systems to safely keep records in a facility that also protects from fire, rodents, and other risks.

Keep Records Accessible

Information sometimes needs to be retrieved by companies immediately, and it needs to be accessible. Not only does a records management service get the physical files off site to avoid taking up valuable space, but their system allows for access to specific information when needed. Having access to needed information helps protect a company legally, helps meet compliance with regulatory obligations, and increases efficiency.

Data Backup

The amount of data that needs to be digitally stored is overwhelming for a business. This data needs to be backed up and stored consistently while also allowing for easy access. A records management service can facilitate the data back up and safely store it, and allow for easy recovery.

A records management service offers off site and highly secure storage of media. Sometimes specialized storage of items is needed for things such as tapes, discs and CD ROMs, and a records management company has the facilities to store them appropriately. The information is not only safeguarded, but it is easily recovered.

Privacy, data protection, and identity theft are important current issues for records management, so paper shredding and document destruction are crucial for protecting your company from making mistakes. Not only criminals could be looking through trash or unsecured storage for confidential information, but competitors and the news media. The information should be destroyed thoroughly so confidentiality is not compromised.

Category : | Read More......

If you are making database applications for end users, you have probably received requests from your users to add yet another type of query more than once. When developing a database, one can never foresee all possible types of queries in advance. In real life, something important - or rarely used - can easily be omitted from the code. For example, your users may want to locate all female customers born after 1969. Or all patients with certain diagnosis who are given particular treatments or certain drugs. Or all passengers who travelled to certain destinations at certain dates last year. Or all customers who've spent more than X dollars during the last holiday season. Dealing with this type of customer requests require additional support efforts and extra time on modifying existing code, which is hardly exciting.

Fortunately, there is a solution. If you are in a position to choose which database components to pick for your next project, get one that allows your users to submit custom queries as easy as possible. Ideally, the component would be completely transparent to the user, involving no calls to your technical support department.

EasyQuery http://devtools.korzh.com/eq/ is not just another one of the many developer-oriented database components. Offering unique user-friendly approach, EasyQuery is the first user-oriented database query solution on the market. Relieve your technical support department of requests asking to implement additional types of queries - your users will be able to do it on their own without you having to modify the application! Hard to believe? Try an online implementation of the system at http://ajax.easyquerydemo.com/ and design a few queries to see how easy it is!

EasyQuery helps your users to run any queries on a database they can imagine - without contacting your support team and without having to write a single line of code. They build their queries by simply pointing and clicking and without using cryptic internal field names such as CustNo, LName, or OrdDate. Instead, they would pick "Customer Number", "Last Name" and "Order Date" as the names of the columns, and use human language instead of database language. For example, they would use "begins with" instead of LIKE 'A%', "greater than" instead of ">", and so on. In case there's a limited selection of values, such as the name of a country, they'll be able to pick a value from a drop-down box instead of typing it.

>From the developer standpoint, EasyQuery is truly universal. Supporting many different databases, it can be used with MS SQL Server, Oracle, MySQL, Microsoft Access, and many other databases. EasyQuery is as easy to implement as it is to use, only requiring 20-30 minutes of your time to get started. The library offers unlimited expansion possibilities with a set of flexible APIs. The solution supports a multitude of development environment, and is supplied in the form of Delphi components, ActiveX controls, .NET Windows Forms components, or ASP.NET controls (with AJAX support) depending on your needs.

Extend your database application with unlimited, user-driven queries! Visit http://ajax.easyquerydemo.com/ to use an on-line demo, or browse directly to http://devtools.korzh.com/eq/ to learn more about EasyQuery and to download a free evaluation copy.

Category : | Read More......

Following is the full syntax used for creating database in Sql Server 2005.

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

CREATE DATABASE database_name

[ ON [ PRIMARY ] [ <>] ]

{ LOG ON [ <> ] ]

<> : : =

( [ NAME = logical_file_name , ]

FILENAME = 'os_file_name'

[ , SIZE = size ]

[ , MAXSIZE = { max_size | UNLIMITED } ]

[ , FILEGROWTH = growth_increment ] ) [ ,.... n ]


Description ::-

ON specifies the disk file used to store the data portion of the database.

LOG ON specifies the disk files used to store log files.

FILENAME=os_file_name specifies the operating-system file name for the file.

PRIMARY specifies the associated list that defines files in the primary filegroup.

NAME=logical_file_name specifies the logical name for the file.

MAXSIZE=max_size specifies the maxium size to which the file defined in the list can grow.

FILEGROWTH=growth_increment specifies the growth increment of the file defined in the list.

Remember - " FILEGROWTH setting for a file cannot exceed the MAXSIZE setting"

NOTE : Everything written between [ ] is optional .

But remeber that to create a database you must be a member of the dbcreator server role.

After a database is created, to check details of the database use following command :

sp_helpdb [ database_name ]

To drop a user defined database use following command:

DROP DATABASE database_name

Note: you cannot delete a system-defined database.

To rename a user-defined database use :

sp_renamedb old_database_name , new_database_name

Fortunately you can also create a database by a right click on the object explorer, Thanks to SQL SERVER Management studio 2005.

SQL SERVER 2005 contains the following system database :


  1. master

  2. tempdb

  3. model

  4. msdb

  5. Resource

Category : | Read More......

Joins in Sql-server

Diposkan oleh : ghetux On 12:46 PM 0 komentar

Just open SQL-Server and start typing the following(for spoon feeding u can also Copy and Paste):

What are Joins- Joins retrieve combination of two tables on the basis of a desired match.

Types of Joins-

  • Inner(Equi Join, Natural Join, Cross Join)

  • Outer(Left Outer Join, Right Outer Join, Full Outer Join)

  • Self Join

/* Note: #Join implicitly means Inner Join

#Outer Join must be supplied with either of left, right or full keyword */

Create First Table Department-

create table Department

(

DepartmentID int PRIMARY KEY,

DepartmentName varchar(50)

)

/* Here DepartmentID will be Primary Key */

Insert some values in Department Table-


insert into Department values(1,'HR')

insert into Department values(2,'Admin')

insert into Department values(3,'Establishment')

insert into Department values(4,'SoftwareDevelopment')

insert into Department values(5,'Clerical')

Create Second table Employee-

create table Employee

(

EmployeeID int PRIMARY KEY IDENTITY,

EmployeeName varchar(50),

DepartmentID int foreign key references Department(DepartmentID)

)

/* Here DepartmentID is foreign key */


Insert some values in EmployeeTable-


insert into Employee values('Jazz',2)

insert into Employee values('Mic',2)

insert into Employee values('Joe',3)

insert into Employee values('Sam',5)

insert into Employee values('Aby',5)

insert into Employee values('Jazz',3)

insert into Employee values('Rai',2)

insert into Employee values('Tarry',2)

insert into Employee values('Shally',1)

insert into Employee values('Akash',2)

select * from Department,Employee

where Department.DepartmentID=Employee.DepartmentID

/*The above query generates a a table containing all the records where DepartmentID in both the tables are same The same result can be obtained by performing inner join on both the tables*/


/*****INNER JOIN*****/

select * from Department INNER JOIN EmployeeON Department.DepartmentID=Employee.DepartmentID

/*****Equi Join*****/

select * from Department INNER JOIN Employee

ON Department.DepartmentID=Employee.DepartmentID

/*The above query also fetches the same result as Equijoin(or Theta Join) is necessarily similar to Inner Join operation but the difference lies in the fact that Inner Join may be done on the basis of any other predicate condition other than '='

See tne following Example for this*/

select * from Department INNER JOIN Employee

ON Department.DepartmentID>Employee.DepartmentID


/*****Natural Join*****/

select * from Department NATURAL JOIN Employee

/*The above query generates same result with the only difference that Natural join gives only one identical column*/

/*SQL Server doesnot support this syntax it fetches natural join of two tables by using INNER JOIN operation

Visit the link: http://blog.sqlauthority.com/...7/sql-server-get-common-records-from-two-tables-without-using-join*/


/*****Cross Join*****/

select * from Department CROSS JOIN Employee /*Cross Join gives Cartesian Product -shows records if join condition is true or completely absent*/

/*****OUTER JOIN*****/

/*Doesnot necessarily contain all the matching records each record is retained even if no matching record exists*/

/*****Left Outer Join*****/

select * from Department LEFT OUTER JOIN EmployeeON Department.DepartmentID=Employee.DepartmentID /* It gives all records from the first table even if there is no match in the second table For instance in this example there is no Employee working in Department 4 (Software development)*/

/*****Right Outer Join*****/

select * from Department RIGHT OUTER JOIN Employee

ON Department.DepartmentID=Employee.DepartmentID

/*It gives all records from the second table even if there is no matching record in the first. Here in this example all Employee belong to some or the other Department*/select * from Department FULL OUTER JOIN EmployeeON Department.DepartmentID=Employee.DepartmentID /*It shows all the records from both the tables & fills with NULL where no matching occurs*/

/*****SELF JOIN*****/

/*Applied to the same table*/

select A.EmployeeID,A.EmployeeName,B.EmployeeID,B.EmployeeName,A.DepartmentID

from Employee A,Employee B

where A.DepartmentID=B.DepartmentID

/*The above query retrieves combinatios of all Employees working in same Department from the Employee table*/

That's all with joins!!

Shees Abidi,

Category : | Read More......

Mysql Schema in C#

Diposkan oleh : ghetux On 12:25 PM 0 komentar

Figure 1.0: Screenshot of MySQL Utility.

Introduction

This article covers how to talk to MySQL database and extract the schema from it.

Background

As many of you know, MySQL is an open source database. It is free for non-commercial purposes. This article would be helpful for anybody doing development in MySQL and C#. What is the motivation behind this utility? Well, an application could crash in the middle of database activities. Often, these databases may not reside on the same site as your development/testing machine. We need a utility that would help us get a snapshot of the database at client site. If you have an utility that would capture the state of the client database, then, you can load it in your testing machine. The idea is to reproduce the situation your client faced. That way you can address any undiscovered issues.


Functionality Supported



  • Saving Schema as Text

  • Viewing Schema

  • Viewing Entire Database


Required Tools



  • ODBC.NET Data Provider from Microsoft

  • MySQL Database

  • MySQL ODBC Connector


Using the code


First, add a reference to Microsoft ODBC. Then use the using microsoft.odbc statement to tell it that you want to you MS ODBC. In short, OdbcConnection will be used to open connection, OdbcCommand to execute queries, and OdbcDataReader to read the resulting row set. The code shown below documents each step. You will notice, it runs the MySQL specific command SHOW TABLES to get the list of tables. Then it runs another query based on that particular table, SHOW COLUMNS IN CURRENT_TABLE. This is all the code does.


The Code


Collapse /*/////////////////////////////////////////////////////////////////////////
//
@@ Function:
@f ::PrepareSchema
//
@@ Description:
@d when this is called the widget is updated and everything
// about this database and tables are displayed
//
@@ Type:
@t public
//
@@ Arguments:
// none.
@@ Returns:
@r void
//
@@ Preconditions:
@c Provided that the GUI is running and DB Connection is made.
//
@@ Postconditions:
@o DB schema displayed
//
@@ References:
@e http://www.pcquest.com/content/linux/handson/102031401.asp%22\" target="_blank">Query MySql with C#.
//
/////////////////////////////////////////////////////////////////////////*/

public void PrepareSchema()
{
// create the connection object by setting the DSN

OdbcConnection ocConnection = new OdbcConnection("DSN="+ strDSN);

// second connection is created so we could make

// queries while executing one

OdbcConnection ocConnection2 = new OdbcConnection("DSN="+ strDSN);

// this will open up both connections

ocConnection.Open();
ocConnection2.Open();

// declare the commands for each table and column

OdbcCommand ocTableCommand;
OdbcCommand ocColumnCommand;

// create a command object. this will execute SHOW TABLES

// query. In mysql, it shows all of the tables contained in

// the database in use.

ocTableCommand = new OdbcCommand("SHOW TABLES", ocConnection);

// declare reader objects for tables and columns

OdbcDataReader odrTableReader;
OdbcDataReader odrColumnReader;

// queries that return result set are executed by ExecuteReader()

// If you are to run queries like insert, update, delete then

// you would invoke them by using ExecuteNonQuery()

odrTableReader = ocTableCommand.ExecuteReader();

// place create db statement in rich text box

rchtxtSchema.Text += "CREATE DATABASE ";
rchtxtSchema.Text += ocConnection.Database;
rchtxtSchema.Text += ";\r\n\r\n";

rchtxtSchema.Text += "USE DATABASE ";
rchtxtSchema.Text += ocConnection.Database;
rchtxtSchema.Text += ";\r\n\r\n";

string strTable = "";
string strColumnName = "";
string strColumnType = "";
string strColumnNull = "";
string strColumnPKey = "";
string strColumnDflt = "";
string strColumnExtr = "";

// reader the set of tables

while(odrTableReader.Read())
{
// here we are expecting rows with only 1 column

// containing the table name. that's why explcity

// call GetString() at 0th index

strTable = odrTableReader.GetString(0);

rchtxtSchema.Text += "CREATE TABLE ";
rchtxtSchema.Text += strTable;
rchtxtSchema.Text += "\r\n(\r\n";

// build up the command for each table

ocColumnCommand = new OdbcCommand("SHOW COLUMNS IN " +
strTable, ocConnection2);

// run the query

odrColumnReader = ocColumnCommand.ExecuteReader();

// reading the set of columsn

while(odrColumnReader.Read())
{
// This query returns the name of column, Type,

// wherther it's Null, whether it's primary Key,

// the default value, and extra info such as

// whether it's autoincrement or not

strColumnName = odrColumnReader.GetString(0);
strColumnType = odrColumnReader.GetString(1);
strColumnNull = odrColumnReader.GetString(2);
strColumnPKey = odrColumnReader.GetString(3);
//strColumnDflt = odrColumnReader.GetString(4);

strColumnExtr = odrColumnReader.GetString(5);

if (!strColumnNull.Equals("YES"))
strColumnNull = " NOT NULL ";
else
strColumnNull = "";

if (strColumnPKey.Equals("PRI"))
strColumnPKey = " PRIMARY KEY ";

//this.rchtxtSchema.Text += "\n";

rchtxtSchema.Text += " ";
rchtxtSchema.Text += strColumnName;
rchtxtSchema.Text += " ";
rchtxtSchema.Text += strColumnType;
rchtxtSchema.Text += strColumnPKey;
rchtxtSchema.Text += strColumnNull;
rchtxtSchema.Text += ",";
rchtxtSchema.Text += "\r\n";

}

rchtxtSchema.Text = this.rchtxtSchema.Text.Substring(0,
this.rchtxtSchema.Text.Length-3);
rchtxtSchema.Text += "\r\n);\r\n\r\n";

// free up the reader object

odrColumnReader.Close();
}

// close the reader

odrTableReader.Close();

// disconnect

ocConnection.Close();
ocConnection2.Close();
}


Points of Interest


Initially, I kept going back and forth from ODBC, ADODB and OLEDB to implement this. According to MySQL, it is not safe to use OLEDB. There was no mention of how to utilize OLEDB to perform simple database tasks. At the end, it was decided doing this would be very simple in ODBC. You have probably noticed that I used built-in commands (i.e. show tables) that the specific DB provider uses. I am definitely open to any suggestions or working examples of standards that work with MySQL.


HOW-TO use this Demo


Saving Schema


First, click on Select the Target Database. This should produce the dialog box showing the list of system as well as user DSNs.


DSN Dialog


Figure 2.0 - Depicts the DSN dialog form.


Now, click on Save Schema File As and select where you wish to save the file.


File Save Dialog


Figure 3.0 - Depicts the File Save dialog.


Next, make sure Save Schema is checked. Then click on Run.


Operation Status


Figure 4.0 - Depicts the status of operation. In this example, the program successfully wrote C:\s01user38_schema.txt.


Viewing Schema


First, uncheck Save Schema and then check View Schema. It should produce the output as depicted in figure 5.0


Schema View


Figure 5.0 - Depicts the schema of s01user38.


Viewing Database


Now, click on View Database in Grid and press Run.


Database in Grid


Figure 6.0 - Depicts the result of the query. It will show + initially. You have to click on it to expand all. Then it will show the tables as shown in this graphic. Then click on each blue link to see the rowset they contain.

Category : | Read More......

About Me

My photo
"im the man not superman"

SPONSOR


Masukkan Code ini K1-YA6F17-2
untuk berbelanja di KutuKutuBuku.com

Followers