Tables in DBMS

A database is a collection of related data. Each of these datas is grouped into different related groups. Each of these groups is stored in the physical memory like disks in the form of bits. But when a user wants to see some specific data, if he is given in the form of bits, he will not understand what it is. Also, in the memory records are scattered in different data blocks and it will not be in any order. But user would always like to see a meaningful and formatted data. Hence the user is given a logical view of the data stored in the database. This is achieved by displaying the records in the form of a table with rows and columns. Each column in the table forms the related set of information of an object. Object can be anything in the real world –either living or non-living. For example, if we consider Pen as an object, we can create a table for it with columns like its name, type, pen color, ink color, orientation, weight, ease of use etc. Basically column contains the specification or details about the object with which a table is created. Rows of the table contain the value for these entire columns. Each row will have specific values related to single object. For example, a pen (Reynolds, Ballpoint, Blue, blue, linear, .5, Yes) will be specific to one type of pen. There can be multiple types of pen, and each specification of them forms different rows.

This is the logical view of the data. In a database a table can be created by using SQL as follows :

CREATE TABLE table_name (column1 DATATYPE, column2 DATATYPE… columnN DATATYPE);

CREATE TABLE PEN (NAME VARCHAR2 (15), 
TYPE VARCHAR2 (10), 
PEN_COLOR VARCHAR2 (15),
INK_COLOR VARCHAR2 (15),
ORIENTATION VARCHAR2 (15),
WEIGHT NUMBER (3, 2),
EASE_OF_USE BOOLEAN);

 The table can be accessed using SELECT query.

SELECT * FROM PEN;
	
SELECT * FROM PEN WHERE INK_COLOR = ‘Red’;
Translate »