0% found this document useful (0 votes)
7 views3 pages

Mysql

Uploaded by

xyz982943
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Mysql

Uploaded by

xyz982943
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

What is a Database?

A database is an organized collection of structured information, or data, typically stored


electronically in a computer system. A database is usually controlled by a database
management system (DBMS)

A Relational DataBase Management System (RDBMS) is software that:

 Enables you to implement a database with tables, columns and indexes.


 Guarantees the Referential Integrity between rows of various tables.
 Updates the indexes automatically.
 Interprets an SQL Query and combines information from various tables.

RDBMS Terminology

Before we proceed to explain the MySQL database system, let us revise a few definitions
related to the database.

Table: A table is a matrix with data. A table in a database looks like a simple
spreadsheet.

Column:Field – Attribute :One column contains data of one and the same kind,
for example the column Name, Roll.

Row: A row –tuple or record is a group of related data.


For example, the data of one person, Thing.

Degree – Number of columns are known as Degree of the table.

Cardinality: Number of rows in a table is known as cardinality.

Redundancy: Storing data twice, redundantly to make the system faster.

Constraints:

Constraints are the condition which are defined when creating table and applied by the sql
automatically when data is insert or update in a table to ensure validity of the data, called Constraints.

 Primary Key
 Not null
 Unique
 Default
 Foreign key
Create table student(
Rollnoint Primary key,
Name varchar(25) Not Null,
Email varchar(25) unique,
Hobby varchar(25) default ‘Music’);
Foreign key:

Create table exam (Rollno integer,


phyint,cheint,mathint,
Foreign key(Rollno) references student(Rollno))
Key:-

Primary Key: In a primary key we cannot store null and duplicate value.

Candidate Key: Set of columns which uniquely define the values.

Alternate Key: One of candidate is selected as primary key remaining are known as
alternate.

Foreign Key: in a foreign key column we can store only those value which are already
stored in primary key this primary key and foreign key are define when creating table.

Referential Integrity: Referential Integrity makes sure that a foreign key value always
points to an existing row.

Data Types in Mysql :

Data Types : char, varchar, int, float, date.


INT − A normal-sized integer from -2147483648 to 2147483647.

TINYINT − A very small integer that can allowable range is from -128 to 127.

SMALLINT − A small integer that can be allowable range is from -32768 to 32767.

MEDIUMINT − A medium-sized integer that can be allowable range is from 0 to


16777215. You can specify a width of up to 9 digits.

BIGINT − A large integer that can be signed or unsigned. If signed, the allowable range is
from -9223372036854775808 to 9223372036854775807.

FLOAT(M,D) − A floating-point number

DOUBLE(M,D) − A double precision floating-point

DECIMAL(M,D) − An unpacked floating-point number that cannot be unsigned. In the


unpacked decimals,

Date and Time Types

The MySQL date and time datatypes are as follows −

DATE − A date in YYYY-MM-DD format,

DATETIME − A date and time combination in YYYY-MM-DD HH:MM:SS format

TIME − Stores the time in a HH:MM:SS format.

YEAR(M) − Stores a year in a 2-digit or a 4-digit format.


DDL-
 Create – Database , Table
 Alter – Column – Add, Drop, Modify
 Drop – Database , Table
DML
 Insert into –
 Value for all column
 Value for limited column
 Multiple Record at a time
 Delete
 Delete All Records
 Delete on specific record
 Update
 Update specific column value for one record
 Update a column value
 Update Multiple columns for one or more record
 Select - distinct , order by
 Where Clause
And, Or, in, between, like, not like, is null, is not null, Group by Having

Differentiate between Null and Zero.


Null Zero
System define Value User define Value
Null is not consider in Zero isconsider in
Aggregate Function Aggregate Function
We can’t perform arithmetic We can perform arithmetic
on zero

Differentiate between char and varchar.


Char Varchar
Fix Size length Variable size length
Default Size one Default size is zero

Differentiate between Drop and Delete.

Drop Delete
DDL Command DML Command
To drop Structure To delete Data

You might also like