Curriculum
Course: SQL
Login
Text lesson

Introduction

 

Briefly, a database is the collection, organization, and presentation of information.

It makes it manageable to evaluate an organization’s goal. It allows research into the outcome.

Record keeping is not a recently invented methodology. It comes with human evaluation. Historically, our ancestors collected and organized data to maintain their ideas.

Today, we prefer to collect, record, and organize data to input, process, and output it, so various methods exist for collecting and organizing information.

Table: 1.1 Example of Database Table

SN

Name

City

Country

1

Tom

Toronto

Canada

2

Jack

Parth

Australia

3

Thompson

New York

Thompson

4

Samita

Kolkata

India

5

Chayo

Bejing

China

A brief introduction to SQL terminology

 

Database: A logical container for data.

Entity: An object, such as a person, a car, a song, or a video

Attributes: A characteristic of an entity; an example is a model of a car

The term datatype refers to the type of data or attribute. For example, varchar, date, and integer.

Column: The column contains values. It belongs to a specific field or entity.

Row: It is complete information about a specific entity.

Record: All information about the entity is a record.

 

Data Type

The data type in a database specifies the type of data that can be stored and manipulated within the databaseIt defines the values that a variable or attributes allow and the process that can be performed on those values. Data types help ensure data integrity and optimize data storage and processing.

Expression:

An expression is a kind of variable, constant, operator, and function that evaluates to a single value. Expression is executed by performing calculations, making decisions, and manipulating data.

String

String data types are used to store a set of characters such as letters, numbers, words, sentences, symbols, and even paragraphs. In order to handle text information such as name, address, phone no, and other text information, string data types are essential.

Table 1.2: String Data Types

Data Type

Description

Contain type (bytes)

Length Size (bytes)

Storage (bytes)

Example

Character (Char)

Fixed string length size

letters, numbers, and special characters

0–255

1-8000

CHAR(5)

Variable Character (Varchar)

Variable string length size

letters, numbers, and special characters

0–65,535

1-8000

Varchar(10)

Variable Character (Varchar (Max)

Variable string length size

letters, numbers, and special characters

0–2,147,483,647

1-8000

Varchar(MAX)

Numeric

In SQL, numerical data types are used to store numbers that can be manipulated mathematically. Various arithmetic operations can be carried out on these data types, including addition, subtraction, multiplication, and division. The following categories can be applied to numerical data types:

Table 1.3: Numeric Data Type

Data Type

Descreption

Contain type

Length Size

Storage

Example

Integer

Allow to storing whole numbers without decimal points

Whole number

 -2,147,483,648 to 2,147,483,647

4 bytes

Example_Age int

DECIMAL

Allow to storing fixed number of digits after the decimal point

Real number

p=65 and d=30

defult p=10 and s=0

 1-9=510-19=9

20-28=13

29-38=17

Example_Price DECIMAL(5, 2)

DECIMAL[(P[,S])]

* P = PRECISION

*S=SCALE 

Date and Time

Date and time data types store information related to dates, times, and timestamps. They allow for various operations and analyses on date and time values.

 

Table 1.4: Data and Time Data Types

Data type

Description

Format

Range

Example

DATE

Allow to store year, month and day

YYYY-MM-DD

 '1000-01-01' to '9999-12-31'

2020-12-26

TIME

Allow to store time

HH:MM:SS

-838:59:59' to '838:59:59

12:12:12

DATETIME

Date and time information allow to store

YYYY-MM-DD hh:mm:ss.

'1000-01-01 00:00:00' to '9999-12-31 23:59:59'

2020-12-26 12:12:12

TIMESTAMP

Store date, time and zone information

YYYY-MM-DD hh:mm:ss. UTC

 '1000-01-01 00:00:00' UTC to '9999-12-31 23:59:59' UTC

2020-12-26 12:12:12, LA

There are sample questions about the database. It could be true-false or multiple-choice. It helps to know about databases before diving into the course.

It might also be beneficial to you as a learner.

Â