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

Database Theory

DBMS stands for Database Management System and is software that allows users to create, access, manage and control databases. A DBMS allows users to create, read, update and delete data in a database. RDBMS stands for Relational Database Management System and stores data in tables with rows and columns. The document discusses different database concepts including data types, schema, normalization, SQL commands and users.

Uploaded by

itikhed971
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Database Theory

DBMS stands for Database Management System and is software that allows users to create, access, manage and control databases. A DBMS allows users to create, read, update and delete data in a database. RDBMS stands for Relational Database Management System and stores data in tables with rows and columns. The document discusses different database concepts including data types, schema, normalization, SQL commands and users.

Uploaded by

itikhed971
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

What is DBMS?

Database Management Systems (DBMS) are software systems


used to store, retrieve, and run queries on data. A DBMS serves as an
interface between an end-user and a database, allowing users to create,
read, update, and delete data in the database.
Data is the smallest unit of information that can be collected,
stored and processed to extract useful information. There are many
forms in which data can be found, such as text, audio, images, video,
and more.

What Is Database In SQL


A database in SQL is a collection of tables which store data in an
organised manner. We use SQL, which allows users to interact with the
data using various SQL commands. SQL (Structured Query Language)
is a programming language used to manipulate or manage the relational
database using SQL commands. We can create, retrieve, update, and
delete data in a database.
 Database Creation: To create a database using CREATE
DATABASE using a user-defined name for the database.

Query to create a Database in SQL


CREATE DATABASE database_Name;

Relational database concepts


A relational database management system (RDBMS) stores and retrieves
data that is represented in tables. A relational database consists of a
collection of tables.

What is difference between Rdbms and DBMS?


What is the Difference between DBMS and RDBMS? DBMS stands for
Database Management System, and RDBMS is the acronym for the
Relational Database Management system. In DBMS, the data is stored as a
file, whereas in RDBMS, data is stored in the form of tables.

RDBMS stores data in the form of tables, whereas DBMS stores


data in the form of files.

What are the Data Models in DBMS?

Data Models in DBMS: Data models specify how data is linked to one another, as well as how it is handled
and stored within the system.
Database Users
A Database User is defined as a person who interacts with data daily, updating,
reading, and modifying the given data. Database users can access and retrieve data
from the database through the Database Management System (DBMS) applications
and interfaces.

Types of Database Users


Database users are categorized based on their interaction with the database.

1.Database Administrators (DBA)


Database Administrators (DBA) are the most important type of database users in DBMS.
Database Administrator is an individual or a team of users who define the database schema and
takes charge of controlling various levels of the database within the organization.

Database Administrators (DBAs) have full control of the database and they are sometimes
known as the super-users of the database.

2. Naive / Parametric End Users


Parametric End Users are the unsophisticated who don’t have any DBMS knowledge
but they frequently use the database applications in their daily life to get the desired
results. For example, Railway’s ticket booking users are naive users
3. A System Analyst
A system Analyst is a user who analyzes the requirements of parametric end users.
They check whether all the requirements of end users are satisfied.
4. Sophisticated Users
Sophisticated users can be engineers, scientists, business analyst, who are familiar
with the database. They can develop their own database applications according to
their requirement. They don’t write the program code but they interact the database
by writing SQL queries directly through the query processor.
5. Database Designers
Data Base Designers are the users who design the structure of database
6. Application Programmers
Application Programmers also referred as System Analysts or simply Software
Engineers, are the back-end programmers who writes the code for the application
programs. They are the computer professionals. These programs could be written in
Programming languages such as Visual Basic, Developer, C, FORTRAN, COBOL
etc

What is a database schema?


A database schema defines how data is organized within a relational
database; this is inclusive of logical constraints such as, table names, fields,
data types and the relationships between these entities.
Normalization
Normalization rules divides larger tables into smaller tables and links them
using relationships. 1NF, 2NF, and 3NF are the first three types of database normalization.
They stand for first normal form, second normal form, and third normal form, respectively.
What Are the Data Types in MySQL?
Every database column has a name and a data type. The specified data
type tells MySQL what kind of values the column stores, how much
space it requires, and what type of operations it can perform with the
data.
MySQL String Data Types

CHAR(Size) It is used to specify a fixed length string that can contain


numbers, letters, and special characters. Its size can be 0 to 255
characters. Default is 1.

VARCHAR(Size) It is used to specify a variable length string that can contain


numbers, letters, and special characters. Its size can be from 0 to
65535 characters.

BINARY(Size) It is equal to CHAR() but stores binary byte strings. Its size
parameter specifies the column length in the bytes. Default is 1.

VARBINARY(Size) It is equal to VARCHAR() but stores binary byte strings. Its size
parameter specifies the maximum column length in bytes.

TEXT(Size) It holds a string that can contain a maximum length of 255


characters.

MySQL Numeric Data Types

BIT(Size) It is used for a bit-value type. The number of bits per


value is specified in size. Its size can be 1 to 64. The
default value is 1.

INT(size) It is used for the integer value. Its signed range varies
from -2147483648 to 2147483647 and unsigned range
varies from 0 to 4294967295. The size parameter
specifies the max display width that is 255.

INTEGER(size) It is equal to INT(size).

MySQL Date and Time Data Types

DATE It is used to specify date format YYYY-MM-DD. Its supported


range is from '1000-01-01' to '9999-12-31'.

YEAR It is used to specify a year in four-digit format. Values allowed in


four digit format from 1901 to 2155, and 0000.
How to create Database and tables in SQL
Database in SQL

CREATE DATABASE database_Name;

 Creating Table: Tables are created using the CREATE TABLE command.
Create table in SQL

CREATE TABLE table_name (

column1 datatype,

column2 datatype,

);

SQL Commands
Data Definition Language (DDL) Commands

What is DDL?

DDL, which stands for Data Definition Language, is a subset of SQL (Structured Query
Language) commands used to define and modify the database structure. These commands are
used to create, alter, and delete database objects like tables, indexes, and schemas. The primary
DDL commands in SQL include:

1. CREATE: This command is used to create a new database object. For example,
creating a new table, a view, or a database.
 Syntax for creating a table: CREATE TABLE table_name (column1 datatype, column2
datatype, ...);
2. ALTER: This command is used to modify an existing database object, such as adding,
deleting, or modifying columns in an existing table.
 Syntax for adding a column in a table: ALTER TABLE table_name ADD column_name
datatype;
 Syntax for modifying a column in a table: ALTER TABLE table_name MODIFY
COLUMN column_name datatype;
3. DROP: This command is used to delete an existing database object like a table, a view,
or other objects.
 Syntax for dropping a table: DROP TABLE table_name;
4. TRUNCATE: This command is used to delete all data from a table, but the structure of
the table remains. It’s a fast way to clear large data from a table.
 Syntax: TRUNCATE TABLE table_name;
5. COMMENT: Used to add comments to the data dictionary.
 Syntax: COMMENT ON TABLE table_name IS 'This is a comment.';
6. RENAME: Used to rename an existing database object.
 Syntax: RENAME TABLE old_table_name TO new_table_name;
Data Manipulation Language (DML) Commands in SQL

Data Manipulation Language (DML) is a subset of SQL commands used for adding (inserting),
deleting, and modifying (updating) data in a database. DML commands are crucial for
managing the data within the tables of a database. The primary DML commands in SQL
include:

1. INSERT: This command is used to add new rows (records) to a table.


 Syntax: INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2,
value3, ...);
2. UPDATE:
3. This command is used to modify the existing records in a table.
 Syntax: UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;
 The WHERE clause specifies which records should be updated. Without it, all records
in the table will be updated.
4. DELETE: This command is used to remove one or more rows from a table.
 Syntax: DELETE FROM table_name WHERE condition;
 Like with UPDATE, the WHERE clause specifies which rows should be deleted.
Omitting the WHERE clause will result in all rows being deleted.
5. SELECT: Although often categorized separately, the SELECT command is sometimes
considered part of DML as it is used to retrieve data from the database.
 Syntax: SELECT column1, column2, ... FROM table_name WHERE condition;
 The SELECT statement is used to query and extract data from a table, which can then
be used for various purposes.
Data Control Language (DCL) Commands in SQL
Data Control Language (DCL) is a subset of SQL commands used to control access to data in a
database. DCL is crucial for ensuring security and proper data management, especially in
multi-user database environments. The primary DCL commands in SQL include:

1. GRANT: This command is used to give users access privileges to the database. These
privileges can include the ability to select, insert, update, delete, and so on, over
database objects like tables and views.
 Syntax: GRANT privilege_name ON object_name TO user_name;
 For example, GRANT SELECT ON employees TO user123; gives user123 the permission to
read data from the employees table.
2. REVOKE: This command is used to remove previously granted access privileges from
a user.
 Syntax: REVOKE privilege_name ON object_name FROM user_name;
 For example, REVOKE SELECT ON employees FROM user123; would remove user123‘s
permission to read data from the employees table.

You might also like