Friday, 24 July 2015

Basic Introduction of DBMS & creating Tables



DBMS

A database management system (DBMS) is a collection of programs that enables you to store, modify, and extract information from a database. There are many different types of DBMS, ranging from small systems that run on personal computers to huge systems that run on mainframes. The following are examples of database applications:

 computerized library systems

 Automated teller machines

 Flight reservation systems

 computerized parts inventory systems

From a technical standpoint, DBMS can differ widely. The terms relationalnetworkflat, and hierarchical all refer to the way a DBMS organizes information internally. The internal organization can affect how quickly and flexibly you can extract information.



Database

A database is a collection of information that is organized so that it can easily be accessed, managed, and updated. In one view, databases can be classified according to types of content: bibliographic, full-text, numeric, and images. They do so through the use of tables . Database tables consist of columns and rows . Each column has certain attributes.

Databases are structured to facilitate the storage, retrieval, modification, and deletion of data in conjunction with various data-processing operations. A database management system (DBMS) extracts information from the database in response to queries.



Tables

A table is a collection of related data held in a structured format within a database. It consists of fields (columns), and rows.

In relational databases and flat file databases, a table is a set of data elements (values) using a model of vertical columns (which are identified by their name) and horizontal rows, the cell being the unit where a row and column intersect.


CREATE DATABASE -

The SQL CREATE DATABASE statement is used to create new SQL database

Syntax:

Basic syntax of CREATE DATABASE statement is as follows:

CREATE DATABASE DatabaseName;

Always database name should be unique within the RDBMS



Eg. CREATE DATABASE FYIT_40;

USE FYIT_40;


The CREATE TABLE Statement

The CREATE TABLE statement is used to create a table in a database.

Tables are organized into rows and columns; and each table must have a name.

  SQL CREATE TABLE Syntax




CREATE TABLE table_name
(
column_name1 data_type(size),
column_name2 data_type(size),
column_name3 data_type(size),
....
);


The column_name parameters specify the names of the columns of the table.

The data_type parameter specifies what type of data the column can hold (e.g. varchar, integer, decimal, date, etc.).

The size parameter specifies the maximum length of the column of the table.



Eg.



CREATE TABLE CUSTOMER

(custno varchar(10) primary key,

cname varchar(20) not null,

cadd varchar(30),

city varchar(20),

pincode integer,

state varchar(20),

creditlimit integer);



CREATE TABLE Persons
(
PersonIDint,
LastNamevarchar(255),
FirstNamevarchar(255),
Address varchar(255),
City varchar(255)
);



CREATE TABLE EMP

(EMPNO NUMBER(4) NOT NULL,

ENAME VARCHAR2(10),

JOB VARCHAR2(9),

MGR NUMBER(4),

HIREDATE DATE,

SAL NUMBER(7, 2),

COMM NUMBER(7, 2),

 DEPTNO NUMBER(2));




CREATE TABLE DEPT
(DEPTNO NUMBER(2),
DNAME VARCHAR2(14),
LOC VARCHAR2(13) );









No comments:

Post a Comment