Day2 Live
Day2 Live
==============
show databases;
use cdac;
show tables;
select * from
--to break
ctrl + c
--Normalization
it is database design techique
it is used to avoid the repeatation of the data / redundancy
we break one table into 2 or more tables in Normalization
Normalization is process , which is followd by database designer or
database architecture
Normalization is performed before creating the tables or inserting the records.
there are 3 Normalization forms.
1NF : 1st normal form
a relation is said to be in “first normal form” (1NF) if and only if all its
attributes assume only atomic values.
pk : orderno+ itemno
===
transitive dependency
----------------->
---------> ----->
c1 c2 c3
10 x aa
20 y bb
30 z cc
10 x aa
20 y bb
=================
==
dml : INSERT, update delete
--1st
insert into emp values ( 3 , 'ritesh' , 32000.00 , 20 , 'p003' )
insert into emp values ( 4 , 'rita' , 32000.00 , 20, null )
insert into emp values ( 5 , 'tej' , null , null, null )
--NOTE
the data, commands is not case sensitive
null : empty
insert into emp values (1, 'vinit', 30000, 10, 'p001');
insert into emp values (2, 'vinit1', 30000, 10, 'p002');
--truncate
will delete all the records, but the structure will be preserved
====
create table emp1(
empno numeric(4),
ename varchar(20),
doj date);
2.15 upto :
2.15 -4.15 : PR
===============
--to see the current time
select current_time();
===========
--to give the comments in mysql
--single line comments
#sdlfksldfk
or
google : emp dept script mysql
===========
--display empno ,ename ,job,
select empno ,ename ,job from emp;
desc emp;
select job from emp;
--to display all the emp details who are receiving the comm
select * from emp
where comm is not null;
--to display all the emp details who are not receiving the comm
select * from emp
where comm is null
or comm=0;
--logical operators
and &&
or ||
not !=
--relational operators
>
<
>=
<=
=
!=
<>
--airthmatic operators
+
-
*
/
--display ename whoes sal > 1000 and who are from deptno 20
select ename from emp
where sal > 1000 and deptno=20;
---------- ----------
1 2
--display ename whoes sal > 1000 or who are from deptno 20
--4
select ename from emp
where sal > 1000 and deptno=20;
--13
select ename from emp
where sal > 1000 or deptno=20;
--display the all details who are working for deptno 10, 20
select * from emp
where deptno =10 or deptno=20
--display the all details who are manager or analyst and whoes sal > 2000
select * from emp
where job in ('manager', 'analyst') and sal > 2000;
--display the all details who are manager , in deptno 10 and who are salesman from
20
select * from emp
where (job='manager' and deptno=10) or (job='salesman' and deptno=20)
--predicates
1 in : exact match
2 between : range
3 like : search for pattern
--tomo
not int
between
like
data types
ER diagrams
aggr fun
constraints
alter