You are on page 1of 15

PROJECT ON SQL DATA TYPE

BY BHARTI . K. SHARMA OF T.Y.B(COM) A ROLL NO:108

DEFINITION OF DATA

A Data is collection of a logically related data.Data involves specifying the types of data ( For Example:-Numeric,Alphanumeric,etc), structures & rules for data to be stored in the database

DATA TYPES IN SQL


Character Data/Text Data (string) Numeric Data (Integer & real) Temporal Data (Data & Time) Boolean Data (True or False) Missing Data (Null)

CHARACTER DATA/TEXT DATA(STRING)


Character data can be stored either as fixedlength or variable-length string. The maximum length for char column is 255 bytes whereas varchar column is 65,535. As matter of fact,if the strings are having fixed length then use char(len) otherwise use varchar(len) Values in CHAR and VARCHAR columns are sorted & compared in case-insensitive fashion,unless the BINARY attribute was specified when the table was created

NUMERIC DATA (INTEGER & REAL)


Numeric data means

numbers and they can be positive or negative or zero;with decimal point or without decimal point.If data is without decimal point then it is integer & if data is with decimal point then it is (float).

TEMPORAL DATA (DATA & TIME)

Temporal data means Date and/or Time.


Type Default Format
YYYY-MM-DD YYYY-MM-DD HH:MI:SS YYYY-MM-DD HH:MI:SS

Storage Required
3 Bytes 8 Bytes 4 Bytes

DATE DATETIME TIMESTAMP

YEAR
TIME

YYYY
HHH:MI:SS

1 Bytes
3 Bytes

If century is not given then century is assumed from 1970 to 2069 i.e.if you give year as 69 then it is taken as 2069 whereas if you give year as 70 then it is taken as 1970.

BOOLEAN DATA (TRUE & FALSE)

Boolean data means true or false.Boolean data value of false is zero or true is nonzero-(generally 1).Storage required is 1 byte.

ENUM
Enum is a list or enumeration of string values.A column of type ENUM can be set to a value from the list.A list can contain maximum 65,535 different values.This column can contain NULL (Stored as 1,2,3).You can prevent NULL values from being accepted by declaring the column as NOT NULL when creating a table.Values stored in database are integers.

MISSING DATA (NULL)

In some cases it is not possible or applicable to provide a value for a particular column in your table.In this case thr column is said to be NULL,which means absence of value.NULL is used for various cases where a value cannot be supplied such as Not Applicable or Unknown or Empty Set

NAME :PINKY YADAV

T.Y.BCOM (A)

PRIMARY KEY

A table typically has a column or combination of columns that contain values that uniquely identify each row in the table. This column, or columns, is called the primary key (PK) of the table and enforces the entity integrity of the table. Because primary key constraints guarantee unique data, they are frequently defined on an identity column.

When you specify a primary key constraint for a table, the Database Engine enforces data uniqueness by automatically creating a unique index for the primary key columns. This index also permits fast access to data when the primary key is used in queries. If a primary key constraint is defined on more than one column, values may be duplicated within one column, but each combination of values from all the columns in the primary key constraint definition must be unique.

AS SHOWN IN THE FOLLOWING ILLUSTRATION, THE PRODUCT AND VENDORID COLUMNS IN THE PURCHASING.PRODUCTVENDOR TABLE FORM A COMPOSITE PRIMARY KEY CONSTRAINT FOR THIS TABLE. THIS MAKES SURE THAT THAT EVERY ROW IN THE PRODUCTVENDOR TABLE HAS A UNIQUE COMBINATION OF PRODUCTID AND VENDORID. THIS

FOREIGN KEY

THANK YOU

You might also like