WHAT IS A DBMS? EXPLAIN DIFFERENT MYSQL COMMANDS AND CONSTRAINTS OF THE SAME.
1. SEMESTER-I
DL03 - Collection Development in Digital Libraries
ASSIGNMENT – C2
WHAT IS A DBMS? EXPLAIN DIFFERENT MYSQL COMMANDS AND
CONSTRAINTS OF THE SAME.
By Shweta Ravindra Bhavsar
Roll No - (2019PGDLIM020)
(2019-2020)
Centre for Library and Information Management Studies
Sir Dorabji Tata Memorial Library
Tata Institute of Social Sciences, Mumbai
2. TABLE OF CONTENTS
1. INTRODUCTION........................................................................................................................................ 1
1.1 Definition.............................................................................................................................................. 1
1.2 Types of Data models ....................................................................................................................... 2
1.3 Characteristic of DBMS.................................................................................................................... 3
1.4 Advantages and Disadvantages of DBMS................................................................................... 3
1.5 Main purpose of DBMS..................................................................................................................... 4
1.6 Applications ........................................................................................................................................ 4
2. MySQL COMMANDS AND CONSTRAINTS ........................................................................................ 4
3. CONCLUSION.......................................................................................................................................... 12
REFERENCES.............................................................................................................................................. 12
LIST OF FIGURES
Fig 1. Three Schema Architecture of DBMS………………………………………………….2
Fig 2. Basic SQL Commands Types…………………………………………………………..5
Fig 3. Create and Show Databases using MySQL commands…………………………….7
Fig 4. Table in MySQL………………………………………………………………………….7
Fig 5. Table with constraints…………………………………………………………………...8
Fig 6. Different range of values………………………………………………………………..8
Fig.7 Table with inserted values………………………………………………………………9
3. 1 | P a g e
1. What is a DBMS? Explain different MySQL commands and constraints of the same.
2. Explain Digital Collection Management and Evaluation in detail. Explain CORAL eRMS
tool.
1. What is a DBMS? Explain different MySQL commands and constraints of the same
Answer
1. INTRODUCTION
The exponential growth of Information and Communicational Technology specifically World
Wide Web (WWW) have significant impact on Database. In 20th and 21st century’s core part
is Data and information. To store, manage and disseminate this Data and Information
databases has emerged out. Database is usually a collection of one or more files that can
be related to each other. Data is basic raw unorganized facts and then this Data is processed
in meaningful way and information is obtained and practical use of information is referred as
knowledge. Before DBMS, “File Processing Systems” were used to store data. Database
management systems (DBMS) defines data structures, types, constraints and provides
access to multimedia data efficiently and conveniently. DBMS is a set of programmes and
developed to organize vast amount of data. Relational Model is defined by Edgar F. Codd
in 1970’s. Ingress, IBM DB2, Oracle these commercial relational database played major role
in DBMS (Database management system). Structured Query Language (SQL) developed in
1990’s which is standard language for relational database management systems. Popular
software of DBMS are SQLite, PostgreSQL, Oracle, MySQL, Microsoft SQL Server, IBM
DB2, etc.
1.1 Definition
(Radványi, n.d.) defined “A database is the whole bulk of integrated and logically connected
pieces of information; the system of data and connections between them; stored abreast.
To be able to work with our database effectively deliberate designing is essential.”
(Radványi, n.d.) stated “The concept of database system consists of the databases, the
computer resources, moreover, in a wider sense, the database-administrators, who are the
ones who put through the designing and programming of the database.”
(Ramakrishnan & Gehrke, 2000) explained database management system, or DBMS, is
software designed to assist in maintaining and utilizing large collections of data, and the
need for such systems, as well as their use, is growing rapidly.
4. 2 | P a g e
Three schema architecture is most commonly used in for web applications. Categorised
into three level first is internal schema (physical level) describe method of storing and
accessing data in database. Conceptual (Logical level) describe the structure of database.
Administrator and the programmers work at this level. External (View level) display the data
to the users.
Fig 1. (“Three Schema Architecture of DBMS,” 2019)
DBMS has three types of users one is administrator who maintain all administrating work
like licencing, required hardware and software, etc. second is Designer who actually create
databases and last one end users. There are two types of database languages. First one
is Data-Definition Language (DDL) which helps database objects to create and modify and
second is Data-Manipulation Language (DML) helps to addition, deletion, and modification
of data.
1.2 Types of Data models
Data models in DBMS describe the pattern of the data in which data can be stored,
organized and manipulated. Based on the data model used. “a collection of conceptual tools
for describing data, data relationships, data semantics, and consistency constraints”. Data
models can be categories into conceptual, Physical, Implementation. Different models are
Network Model and Hierarchical Model, Relational Model, Entity-relationship Model
and Emerging ones are Object-relational and Object-oriented.
1) Hierarchical Model
Hierarchical database model arranges the data into a tree like structure. Only one main
data(parent) and can have infinite sub data(children). This could be one-to-many or one-to-
one relationships among the various data. Single database can include many such tress
and may not be connected to each other and can access a data in a given order. This model
replaced by the relational model.
5. 3 | P a g e
2) Relational Model
Data is stored in two-dimensional tables. In 1970’s E.F Codd introduced this model. The
basic structure is table which contains rows and columns. It is widely accepted model. Single
table also called as relations, records and tables are interconnected to each other. Easy to
build for users as well as application makers.
3) Network Model
This is an inspired by the Hierarchical model. Data is arranged in a graph like structure and
can have multiple main data(parent) of single item and this model make an easy and fast
access. many-to-many data relationships can used by this model.
In Object-oriented represented the real-world in this data is stored in form of objects. Both
data and relationship arrange in a single structure called as object. Object-relational is
amalgam of Relational Model and Object-oriented model, supports inheritance, classes,
objects, etc.
1.3 Characteristic of DBMS
Databases contains data about data i.e. metadata which helps to ease the process. DBMS
provides security to data and minimize data redundancy whenever required. It Is based on
real-world entities and uses behaviour and attributes and also a self-described. DBMS
follows Atomicity, Consistency, Isolation, and Durability (ACID) concept. Multiuser
transaction processing is supported and data can be viewed by many users at the same
time in DBMS. Also, users can manipulate the data but administration can put restrictions
without knowing the users. Entities and relations are interrelated and form table also
maintain consistency. DBMS supported query languages which helps to apply many filters
to retrieve the information.
1.4 Advantages and Disadvantages of DBMS
ADVANTAGES
DBMS can efficiently store and access data by utilizing different techniques. Data
independence changes characteristics of data without disturbing data access programme.
Data integrity helps to maintain data accuracy and consistency. Data security protect
database from unauthorized access. Helps to develop application smartly and quickly can
access database 24*7. Sharing of data and decision making has increased because of well
managed data.
6. 4 | P a g e
DISADVANTAGES
Database management system requires highly skilled professional staff to maintain the
database. Training, hardware and software, licensing etc., overall maintenance cost of
database is high. Database is very complex and using database for several users is not
advisable. DBMS vendors frequently update and upgrade software with new functions.
1.5 Main purpose of DBMS
• To create and maintain a database at ease
• Manage vast amount of information in structured format
• Data storage and recovery
• Provide easy access to users and security to data.
1.6 Applications
Database management systems can be used in every sector like in Banking, Airlines,
Telecommunication, Finance, Manufacturing, etc for maintaining record of their routine work
in respective field. YouTube, Facebook, twitter are also sing DBMS.
2. MySQL COMMANDS AND CONSTRAINTS
American National Standards Institute (ANSI) is standard of Structured Query Language
(SQL) ad used in Relational Database Management Systems (RDMS). In MySQL, SQL use
as a standard database language. MySQL stores a data in a table contains rows will have
different attributes of Sigle records and columns(field) will have specific attribute of different
records. There are different commands and constraints use for building a database.
SQL DATA TYPE
• Integer – For numbers (int)
• Character – fixed length (char) contain letters, numbers, and special characters.
Length from 0 to 255 characters
• Variable Character – variable length alphanumeric (varchar) contain letters,
numbers, and special characters. Length from 0 to 65535 characters
Text – (text) maximum 65535 characters
Name Age Blood group
Sarasvita 24 A+
Satvik 20 O
Record
Attributes
7. 5 | P a g e
TYPES OF CONSTRAINTS It is not applicable for particular item, only for column. This limit
the type of data that can go into a table
1) NOT NULL – cannot be left blank / column cannot have a blank value
2) DEFAULT – set default value when none is provided
3) UNIQUE – ensure value in a column are unique
4) PRIMARY KEY – Uniquely identifies each record/row in a database
It is a combination of NOT NULL and UNIQUE
5) FOREIGN KEY – Uniquely identifies each record/row in other database
6) CHECK – Ensures that all values in a column satisfies a specific condition
COMMAND TYPES There are four command types - DDL (Data Definition Language), DML
(Data Manipulation Language), DCL (Data Control Language), TCL
(Transactional Control Language)
Fig 2. (Basic SQL Commands: DDL, DML, TCL & DQL [Updated], n.d.)
8. 6 | P a g e
SQL LOGICAL OPERATORS Helps to selecting particular records and narrow and
broaden the search as per requirement
AND - Combine or exclude data and narrow the search
NOT - exclude terms from search result
OR – Broaden the search
ALL – Shows all values of selected statement
ANY – Display any of the subquery values meet the condition
BETWEEN - Retrieve values within the range of comparison
SQL COMPARISON OPERATORS Helps to selecting particular records and retrieve the
data using mathematical comparison symbols.
= equal to
> greater than
< smaller than
>= Greater than or equal to
<= smaller than or equal to
<> Not equal to
Note : 1) MySQL does not terminate any command if (;) is not added in the end of
SQL command.
2) Press enter button to execute the command
3) MySQL is case sensitive
a) Open Linux Terminal by Ctrl + Alt +T or go to dashboard and type and search “terminal”
b) Enter sudo su then click enter now put password for admin login.
c) For installation of MySQL use apt-get install mysql-server then set password
d) For login to MySQL use mysql -u root -p command and insert password.
1) Here we will first create database COLLEGES in that will create table ENGINEERINGS
Then will add values in the columns of table.
For creating new databases in MySQL use:
CREATE DATABASE DATABASENAME;
Example CREATE DATABASE SPORTS;
CREATE DATABASE COLLEGES;
9. 7 | P a g e
2) To find out existing databases : SHOW DATABASES;
Fig 3. Create and Show Databases using MySQL commands
3) For selecting particular database for creating tables in which data can be stored.
USE DATABASENAME;
4) To Create table : CREATE TABLE TABLENAME
and put data into ( ); using different data type
By using this command we can create a columns in the database.
After giving above command for creating table; now to check the inserted values are there
in the table for that use below command then table will appear as shown in Fig 2.
DESC TABLENAME;
Fig 4. Table in MySQL
Example USE COLLEGES;
Example CREATE TABLE ENGINEERINGS
(
COLLEGE_ID int(12),
NAME varchar(25),
YEAR int(4),
SUBJECT varchar(10) );
10. 8 | P a g e
Creating table with constraints : This helps to put some restriction on data values
Fig 5. Table with constraints
6) Insert Rows of data :
Mention all the columns name of the selected database in the bracket () and separate
them by comma and Integers to be directly inserted and put text into ‘….’
* For automatically inserting “default” value in the table; do not mention that column
name in the insert command.
Fig 6. Different range of values
Example CREATE TABLE ENGINEERING
(
COLLEGE_ID int(12) NOT NULL UNIQUE,
NAME varchar(25) NOT NULL,
YEAR int(4) DEFAULT 2019,
SUBJECT varchar(10) );
11. 9 | P a g e
7) To see inserted different range of values as shown in Fig. 4 in the table; use command
as given below it will display the table (Fig.5) with values we have entered.
SELECT*FROM TABLENAME;
Fig.7 Table with inserted values
8) To Alter table:
To Add column in the database use below command
ALTER TABLE table_name ADD column_name datatype;
9) To Drop(delete) column from database:
ALTER TABLE table_name DROP column_name;
10) Change Datatype of the field
ALTER TABLE table_name MODIFY COLUMN column_name datatype;
11) Add and modify the Constraint of the field
ALTER TABLE table_name MODIFY column_name datatype CONSTRAINT NAME ;
Example ALTER TABLE ENGINEERINGS MODIFY COLUMN COLLEGE_ID varchar(12);
12. 10 | P a g e
12) SQL COMPARISON OPERATORS :
SELECT*FROM TABLE_NAME WHERE COLUMN_NAME COMPARISON_SIGN VALUE_OF_FIELD;
13) To retrieve the data using SQL LOGICAL OPERATORS :
SELECT*FROM TABLE_NAME WHERE COLUMN_NAME COMPARISON_SIGNS VALUE_OF_FIELD
LOGICAL_OPERATOR COLUMN_NAME COMPARISON_SIGN VALUE_OF_FIELD;
14) SQL Arithmetic Operators
For normal calculation in database use command :
By using below command one can add, substrate, divide, multiple and modify the values
already inserted in particular column.
15) Update Records
16) For Deleting particular Record
Example DELETE FROM ENGINEERINGS WHERE SUBJECT = ‘MATHS’;
Example UPDATE ENGINEERINGS SET SUBJECT= ‘SCINECE’ WHERE YEAR=2019;
13. 11 | P a g e
17) Delete all records : Only records(data) will get deleted but the structure will remain as
it is.
TRUNCATE TABLE TABLENAME;
18) To delete database: Database will get deleted with structure
DROP DATABASE DATABASE_NAME;
19) For taking Backup of Database
BACKUP DATABASE databasename
TO DISK = 'filepath';
20) For adding data format
Here DATE is column
date_format(sal_date,'%d-%m-%y') this command will remain unchanged
21) GRANT
22) REVOKE
Used for taking back permission given to a user.
Example BACKUP DATABASE ENGINEERINGS
TO DISK = 'D:backupstestDB.bak';
Example SELECT COLLEGE_ID,NAME,YEAR,SUBJECT, date_format(sal_date,'%d-%m-%y') as
DATE from ENGINEERINGS;
GRANT object_privileges ON ENGINEERINGS TO 2001001,2001002;
REVOKE object_privileges ON ENGINEERINGS FROM 2001001,2001002;
14. 12 | P a g e
3. CONCLUSION
Database Management system is computerized record maintaining system for collection of
data using different programming languages. Allow users to store, retrieve and maintain
data as per the requirements. Universities, Airlines, Banking are the major areas of
applications of databases. DBMS has replaced by File-processing system with so many
advantages and security. RDBMS is highly in use. One of the example of RDBMS is MySQL
which allows 24*7 updation of data, control the workflow and data security. RDBMS is highly
valuable for creating more advanced web applications in near future.
REFERENCES
1) Basic SQL Commands: DDL, DML, TCL & DQL [Updated]. (n.d.). Retrieved
February15, 2020, from https://hackr.io/blog/sql-commands
2) Database Models in DBMS | Studytonight. (n.d.). Retrieved February 13, 2020, from
https://www.studytonight.com/dbms/database-model.php
3) DBMS - Overview—Tutorialspoint. (n.d.). Retrieved February 12, 2020, from
https://www.tutorialspoint.com/dbms/dbms_overview.htm
5) Radványi, T. (n.d.). Database management systems-DBMS [Lecture notes]. Retrieved
February 13, 2020, from http://lecturenotes.in/materials/19139-note-for-database-
management-system-dbms-by-kiruthika-nagarajan
6) Three Schema Architecture of DBMS. (2019, August 6). Tutorial and Example.
https://www.tutorialandexample.com/three-schema-architecture-of-dbms/
5) What is DBMS? Application,Types, Example,Advantages, Disadvantages. (n.d.).
Retrieved February 12, 2020, from https://www.guru99.com/what-is-dbms.html
6) Ramadevi, G.N. Mukesh, D., & Ruksana, D. (n.d.). Database management systems
[Lecture notes]. Chadalawada Ramanamma Engineering College, Tirupati. Retrieved from
https://lecturenotes.in/notes/44498-note-for-database-management-system-dbms-by-r-
manoj-aiyer
7) Ramakrishnan, R. & Gehrke, J. (2000). Database Management Systems (2nd ed.).
(N.p.): McGraw-Hill Higher Education. Retrieved From https://ff.tu-
sofia.bg/~bogi/knigi/BD/Database%20Management%20Systems.%202nd%20Ed.pdf
8) OECLIB Odisha Electronics Control Library. (2017). Database Management System ppt
[PowerPoint slides]. Retrieved from
https://www.slideshare.net/OECLIBOdishaElectron/database-management-system-ppt