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

Database management System

The document provides an overview of Database Management Systems (DBMS), detailing features such as data modeling, storage, concurrency control, and security. It categorizes DBMS into RDBMS and Non-RDBMS types, listing examples like MySQL and MongoDB, and outlines data languages including DDL, DML, and TCL with SQL commands for database operations. Additionally, it covers table creation, data manipulation, constraints, and joins, illustrating with examples for better understanding.

Uploaded by

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

Database management System

The document provides an overview of Database Management Systems (DBMS), detailing features such as data modeling, storage, concurrency control, and security. It categorizes DBMS into RDBMS and Non-RDBMS types, listing examples like MySQL and MongoDB, and outlines data languages including DDL, DML, and TCL with SQL commands for database operations. Additionally, it covers table creation, data manipulation, constraints, and joins, illustrating with examples for better understanding.

Uploaded by

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

Database management System

Features

1.Data Modeling

2.Data Storage and Retrieval

3.Concurrency Control

4.Data Integrity and security

5. Backup and Recovery

Types of DBMS

1. RDBMS

Foxpro

MS ACCESS

MS SQL Server

ORACLE

MySQL

Database

Tables

Rows and Cols

Data

2. Non-RDBMS

key value pair

document

graph
Mongodb

MariaDB

BiugTable

cassendra

Database

Collections

Document

KeyValue pair

Types of Data Languages

DDL - Data Definition Language

Create - (table, index, view, stored procedure, triggers, functions)

Alter -

Drop -

Truncate -

comment-

rename -

DML -

select -

insert -

update -

merge - upsert -

delete -

Call StoredProcedure

localtable -
(grant,revoke)

grant-

revoke -

TCL -

commit -

rollback -

savepoint -

MySQL

show databases;

create database databasename;

create database lstdb;

use databasename;

use lstdb;

tbl_student

sid int - 11

sname varchar -25

sdepartment text

smobile bigint(15)-default 20

create table tablename(columname1 datatype ,columname2 datatype)


create table tbl_student(sid int,

sname varchar(25),sdepartment text,

smobile bigint(15));

show tables;

desc tablename;

desc tbl_student;

insert into tablename values(value1,value2,value3)

insert into tbl_student values(101,'A','MCA', 9087654321);

inserting for particular columns

insert into tbl_student(sid,sname,sdepartment) values(102,'B','MCA');

multiple records

insert into tbl_student values(103,'C','MCA', 9087654323),(104,'D','MCA', 9087654324);

display all the records

select * from tablename;

select * from tbl_student;

limit

select * from tablename limit value;


select * from tbl_student limit 1;

a particular record

select * from tablename where columnname=value;

select * from tbl_student where sid=101;

a particular column

select columnname1,columnname2 from tablename;

select sid,sname from tbl_student;

update

update tablename set columnname=newvalue where columnname=oldvalue;

update tbl_student set smobile=9087654322 where sid=102;

alter

alter table tablename add column columnname datatype;

alter table tbl_student add column semail varchar(20);

alter table tablename drop column columnname;

alter table tbl_student drop column semail;

first column

alter table tablename add column columnname datatype first;

alter table tbl_student add column semail varchar(20) first;


in between

alter table tbl_student add column semail varchar(20) after sname;

modify the datatype

alter table tablename modify oldcolumnname newdatatype;

alter table tbl_student modify semail text;

change the columname

alter table tablename change oldcolumnname newcolumnname datatype;

alter table tbl_student change semail semailid text;

constraints

primary key

create table tablename(columnname datatype primary key)

by using alter give PK

alter table tablename add primary key(columnname);

alter table tbl_student add primary key(sid);

particular record

delete from tablename where columnname=value;

delete from tbl_student where sid=104;


primary key and unique

both will accept unique record

primary key will not accept NULL values

but Quique will accept null values

AND Query

select * from tablename where columnname=value;

select * from tablename where columnname1=value and columnname2=value;

select * from tbl_student where sid=101 and sname='A';

both the conditions should be true

OR

if any one condition is true then it is true

select * from tablename where columnname1=value or columnname2=value;

select * from tbl_student where sid=101 or sname='A';

AND / OR

select * from tbl_student where sid=101 and (sname='A' or sname='B');

IN

select * from tablename where columnname in (value1,value2,..)

select * from tbl_student where sid in (101,103);


order by

select * from tablename order by columnname;

select * from tbl_student order by sname;

select * from tbl_student order by sname desc;

Like, not like

pattern matching

select * from tablename where columnname like 'pattern%';

select * from tbl_student where sdepartment like 'M%';

select * from tablename where columnname like '%pattern';

select * from tablename where columnname like '%pattern%';

between , not between

select * from tablename where columnname between value1 and value2;

select * from tbl_student where sid between 101 and 104;

select * from tbl_student where sid not between 101 and 104;

tbl_teacher

tid int pk

tname varchar(20)

tsubject text

tsalary decimal(7,2)

create table tbl_teacher(tid int primary key,tname varchar(20),tsubject text,tsalary decimal(7,2))


insert into tbl_teacher values(1001,'sneka','computer science',10000);

insert into tbl_teacher values (1002,'lavanya','data science',20000);

insert into tbl_teacher values (1003,'chintu','tamil',30000);

insert into tbl_teacher values (1004,'pandi',big dta',40000);

foreign key

create table tablename(columnname datatype,foreign key(columnname) references


parenttable(columnname));

alter table tablename add column columnname datatype;

alter table tablename add foreign key(columnname) references parenttable(columname);

alter table tbl_student add column tid int;

alter table tbl_student add foreign key(tid) references tbl_teacher(tid);

join

inner join

select * from tablename1 inner join tablename2 on


tablename1.columnname=tablename2.columnname;

select * from tbl_teacher inner join tbl_student on tbl_teacher.tid=tbl_student.tid;


displays matching records from both the tables

select tid,tname,sid,sname from tbl_teacher inner join tbl_student on


tbl_teacher.tid=tbl_student.tid;

ambiguity error

create a object

select t.tid,t.tname,s.sid,s.sname from tbl_teacher t inner join tbl_student s on t.tid=s.tid;

You might also like