0% found this document useful (0 votes)
2 views

Mysql

A database is an organized collection of records that can be easily accessed and managed by users, typically structured in tables with rows and columns. MySQL is a popular open-source relational database management system known for its speed, scalability, and compatibility with various programming languages. The document also explains key concepts of RDBMS, including tables, rows, columns, data types, and the architecture of MySQL.

Uploaded by

rajavarapu.v
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Mysql

A database is an organized collection of records that can be easily accessed and managed by users, typically structured in tables with rows and columns. MySQL is a popular open-source relational database management system known for its speed, scalability, and compatibility with various programming languages. The document also explains key concepts of RDBMS, including tables, rows, columns, data types, and the architecture of MySQL.

Uploaded by

rajavarapu.v
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

What is Database?

 A database is an application that stores the organized collection of records.


 It can be accessed and manage by the user very easily.
 It allows us to organize data into tables, rows, columns, and indexes to find the
relevant information very quickly.
 Each database contains distinct API for performing database operations such as
creating, managing, accessing, and searching the data it stores.
API - API stands for application program interface. A set of accepted rules
that specify how programmes or computers communicate with one another
is known as an API. Across an application and the web server, APIs act as an
intermediary layer to manage data transit between systems.
How an API works is as follows:
 A client application makes an API request, also known as an API call, to get
information. This request from an application to the web server includes a
request verb, headers, and occasionally a request body. It is handled by the
Uniform Resource Identifier (URI) of the API.
 The external application or web server is called when the API receives a valid
request.
 The desired data is returned by the server in response to an API call.
 The application that performed the first request receives the data from the
AP
 Today, many databases available like MySQL, Sybase, Oracle, MongoDB,
PostgreSQL, SQL Server, etc.

What is MySQL?
 MySQL is currently the most popular database management system software used
for managing the relational database.
 It is open-source database software, which is supported by Oracle Company.
 It is fast, scalable, and easy to use database management system in comparison
with Microsoft SQL Server and Oracle Database.
 It is commonly used in conjunction with PHP scripts for creating powerful and
dynamic server-side or web-based enterprise applications.
---xxx---
What is RDBMS (Relational Database Management System)
All modern database management systems like SQL, MS SQL Server, IBM
DB2, ORACLE, My-SQL, and Microsoft Access are based on RDBMS.
The following are the various terminologies of RDBMS:
What is table/Relation?
 Everything in a relational database is stored in the form of relations. The
RDBMS database uses tables to store data. A table is a collection of
related data entries and contains rows and columns to store data. Each
table represents some real-world objects such as person, place, or event
about which information is collected. The organized collection of data into
a relational table is known as the logical view of the database.
Properties of a Relation:
o Each relation has a unique name by which it is identified in the
database.
o Relation does not contain duplicate tuples.
o The tuples of a relation have no specific order.
o All attributes in a relation are atomic, i.e., each cell of a relation
contains exactly one value.
 A table is the simplest example of data stored in RDBMS.
Let's see the example of the student table.

What is a row or record?


A row of a table is also called a record or tuple. It contains the specific
information of each entry in the table. It is a horizontal entity in the table. For
example, The above table contains 5 records.
Properties of a row:
o No two tuples are identical to each other in all their entries.
o All tuples of the relation have the same format and the same number
of entries.
o The order of the tuple is irrelevant. They are identified by their content,
not by their position.
Let's see one record/row in the table.
What is a column/attribute?
A column is a vertical entity in the table which contains all information
associated with a specific field in a table. For example, "name" is a column in
the above table which contains all information about a student's name.
Properties of an Attribute:
o Every attribute of a relation must have a name.
o Null values are permitted for the attributes.
o Default values can be specified for an attribute automatically inserted if
no other value is specified for an attribute.
o Attributes that uniquely identify each tuple of a relation are the primary
key.

What is data item/Cells?


The smallest unit of data in the table is the individual data item. It is stored
at the intersection of tuples and attributes.
Properties of data items:
o Data items are atomic.
o The data items for an attribute should be drawn from the same domain
In the below example, the data item in the student table consists of Ajeet, 24
and Btech, etc.

Degree:
The total number of attributes that comprise a relation is known as the
degree of the table
For example, the student table has 4 attributes, and its degree is 4.

Cardinality:
The total number of tuples at any one time in a relation is known as the
table's cardinality. The relation whose cardinality is 0 is called an empty
table.
For example, the student table has 5 rows, and its cardinality is 5.

Domain:
The domain refers to the possible values each attribute can contain. It can be
specified using standard data types such as integers, floating numbers,
etc. For example, An attribute entitled Marital_Status may be limited to
married or unmarried values.
NULL Values
The NULL value of the table specifies that the field has been left blank during
record creation. It is different from the value filled with zero or a field that
contains space.
Data Integrity
There are the following categories of data integrity exist with each RDBMS:
o Entity integrity: It specifies that there should be no duplicate rows in a
table.
o Domain integrity: It enforces valid entries for a given column by
restricting the type, the format, or the range of values.
o Referential integrity specifies that rows cannot be deleted, which are
used by other records.
o User-defined integrity: It enforces some specific business rules defined
by users. These rules are different from the entity, domain, or referential
integrity.
---xxx---
 MySQL is a Relational Database Management System (RDBMS) software that
provides many things, which are as follows:
 It allows us to implement database operations on tables, rows, columns, and
indexes.
 It defines the database relationship in the form of tables (collection of rows
and columns), also known as relations.
 It provides the Referential Integrity between rows or columns of various
tables.
 It allows us to updates the table indexes automatically.
 It uses many SQL queries and combines useful information from multiple
tables for the end-users.

How MySQL Works?

MySQL follows the working of Client-Server Architecture. This model is designed for the
end-users called clients to access the resources from a central computer known as a
server using network services. Here, the clients make requests through a graphical user
interface (GUI), and the server will give the desired output as soon as the instructions are
matched. The process of MySQL environment is the same as the client-server model.
The core of the MySQL database is the MySQL Server. This server is available as a
separate program and responsible for handling all the database instructions, statements,
or commands. The working of MySQL database with MySQL Server are as follows:
 MySQL creates a database that allows you to build many tables to store and
manipulate data and defining the relationship between each table.
 Clients make requests through the GUI screen or command prompt by using
specific SQL expressions on MySQL.
 Finally, the server application will respond with the requested expressions and
produce the desired result on the client-side.
Reasons for popularity
MySQL is becoming so popular because of these following reasons:
o MySQL is an open-source database, so you don't have to pay a single penny to use
it.
o MySQL is a very powerful program that can handle a large set of functionality of
the most expensive and powerful database packages.
o MySQL is customizable because it is an open-source database, and the open-
source GPL license facilitates programmers to modify the SQL software according
to their own specific environment.
o MySQL is quicker than other databases, so it can work well even with the large
data set.
o MySQL supports many operating systems with many languages like PHP, PERL, C,
C++, JAVA, etc.
o MySQL uses a standard form of the well-known SQL data language.
o MySQL is very friendly with PHP, the most popular language for web development.
o MySQL supports large databases, up to 50 million rows or more in a table. The
default file size limit for a table is 4GB, but you can increase this (if your operating
system can handle it) to a theoretical limit of 8 million terabytes (TB).
Features of MySQL
One of the major reasons MySQL is considered one of the most popular relational
databases is because of its abundant features. Let us look at them one by one –
 Open-Source - MySQL is open-source, which means this software can be
downloaded, used and modified by anyone. It is free-to-use and easy-to-
understand.
 Quick and Reliable - MySQL stores data efficiently in the memory ensuring that
data is consistent, and not redundant. Hence, data access and manipulation using
MySQL is quick.
 High Performance - MySQL provides comparatively higher performance without
affecting its functionality. It also has a very little memory leakage making it
memory efficient as well.
 Scalable - Scalability refers to the ability of systems to work easily with small
amounts of data, large amounts of data, clusters of machines, and so on. MySQL
server was developed to work with large databases.
 Data Types - It contains multiple data types such as unsigned integers, signed
integers, float (FLOAT), double (DOUBLE), character (CHAR), variable character
(VARCHAR), text, blob, date, time, datetime, timestamp, year, and so on.
 Character Sets - It supports different character sets, and this includes latin1
(cp1252 character encoding), German, Ujis, other Unicode character sets and so
on.
 Secure - It provides a secure interface since it has a password system which is
flexible, and ensures that it is verified based on the host before accessing the
database. The password is encrypted while connecting to the server.
 Support for large databases- It comes with support for large databases, which
could contain about 40 to 50 million records, 150,000 to 200,000 tables and up to
5,000,000,000 rows.
 Platform Independent - MySQL can be run on various operating systems including
Windows, Linux, macOS etc. in several programming languages like C, C++, Java,
Python, Perl, PHP etc.

MySQL Data Types


A Data Type specifies a particular type of data, like integer, floating points, Boolean, etc.
It also identifies the possible values for that type, the operations that can be performed
on that type, and the way the values of that type are stored.
 Numeric Data Type –
Data type Description

BIT(size) A bit-value type. The number of bits per value is specified in size. The size parameter can
hold a value from 1 to 64. The default value for size is 1.

TINYINT(size) A very small integer. Signed range is from -128 to 127. Unsigned range is from 0 to 255.
The size parameter specifies the maximum display width (which is 255)

BOOL Zero is considered as false, nonzero values are considered as true.

BOOLEAN Equal to BOOL

SMALLINT(size) A small integer. Signed range is from -32768 to 32767. Unsigned range is from 0 to 65535.
The size parameter specifies the maximum display width (which is 255)

MEDIUMINT(size) A medium integer. Signed range is from -8388608 to 8388607. Unsigned range is from 0 to
16777215. The size parameter specifies the maximum display width (which is 255)

INT(size) A medium integer. Signed range is from -2147483648 to 2147483647. Unsigned range is
from 0 to 4294967295. The size parameter specifies the maximum display width (which is
255)

INTEGER(size) Equal to INT(size)


BIGINT(size) A large integer. Signed range is from -9223372036854775808 to 9223372036854775807.
Unsigned range is from 0 to 18446744073709551615. The size parameter specifies the
maximum display width (which is 255)

FLOAT(size, d) A floating point number. The total number of digits is specified in size. The number of digits
after the decimal point is specified in the d parameter. This syntax is deprecated in MySQL
8.0.17, and it will be removed in future MySQL versions

FLOAT(p) A floating point number. MySQL uses the p value to determine whether to use FLOAT or
DOUBLE for the resulting data type. If p is from 0 to 24, the data type becomes FLOAT().
If p is from 25 to 53, the data type becomes DOUBLE()

DOUBLE(size, d) A normal-size floating point number. The total number of digits is specified in size. The
number of digits after the decimal point is specified in the d parameter

DOUBLE
PRECISION(size, d)

DECIMAL(size, d) An exact fixed-point number. The total number of digits is specified in size. The number of
digits after the decimal point is specified in the d parameter. The maximum number
for size is 65. The maximum number for d is 30. The default value for size is 10. The
default value for d is 0.

DEC(size, d) Equal to DECIMAL(size,d)

 String Data Types

Data type Description

CHAR(size) A FIXED length string (can contain letters, numbers, and special characters).
The size parameter specifies the column length in characters - can be from 0
to 255. Default is 1

VARCHAR(size) A VARIABLE length string (can contain letters, numbers, and special
characters). The size parameter specifies the maximum column length in
characters - can be from 0 to 65535

BINARY(size) Equal to CHAR(), but stores binary byte strings. The size parameter specifies
the column length in bytes. Default is 1

VARBINARY(size) Equal to VARCHAR(), but stores binary byte strings. The size parameter
specifies the maximum column length in bytes.

TINYBLOB For BLOBs (Binary Large OBjects). Max length: 255 bytes

TINYTEXT Holds a string with a maximum length of 255 characters

TEXT(size) Holds a string with a maximum length of 65,535 bytes

BLOB(size) For BLOBs (Binary Large OBjects). Holds up to 65,535 bytes of data

MEDIUMTEXT Holds a string with a maximum length of 16,777,215 characters


MEDIUMBLOB For BLOBs (Binary Large OBjects). Holds up to 16,777,215 bytes of data

LONGTEXT Holds a string with a maximum length of 4,294,967,295 characters

LONGBLOB For BLOBs (Binary Large OBjects). Holds up to 4,294,967,295 bytes of data

ENUM(val1, val2, val3, ...) A string object that can have only one value, chosen from a list of possible
values. You can list up to 65535 values in an ENUM list. If a value is inserted
that is not in the list, a blank value will be inserted. The values are sorted in
the order you enter them

SET(val1, val2, val3, ...) A string object that can have 0 or more values, chosen from a list of possible
values. You can list up to 64 values in a SET list

Date and Time Data Types

Data type Description

DATE A date. Format: YYYY-MM-DD. The supported range is from '1000-01-01' to


'9999-12-31'

DATETIME(fsp) A date and time combination. Format: YYYY-MM-DD hh:mm:ss. The supported
range is from '1000-01-01 00:00:00' to '9999-12-31 23:59:59'. Adding DEFAULT
and ON UPDATE in the column definition to get automatic initialization and
updating to the current date and time

TIMESTAMP(fsp) A timestamp. TIMESTAMP values are stored as the number of seconds since
the Unix epoch ('1970-01-01 00:00:00' UTC). Format: YYYY-MM-DD hh:mm:ss.
The supported range is from '1970-01-01 00:00:01' UTC to '2038-01-09
03:14:07' UTC. Automatic initialization and updating to the current date and
time can be specified using DEFAULT CURRENT_TIMESTAMP and ON UPDATE
CURRENT_TIMESTAMP in the column definition

TIME(fsp) A time. Format: hh:mm:ss. The supported range is from '-838:59:59' to


'838:59:59'

YEAR A year in four-digit format. Values allowed in four-digit format: 1901 to 2155,
and 0000.
MySQL 8.0 does not support year in two-digit format.

You might also like