0% found this document useful (0 votes)
28 views6 pages

Revision Last Minute - DBMS, SQL and Networ

Uploaded by

ssss23232023
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)
28 views6 pages

Revision Last Minute - DBMS, SQL and Networ

Uploaded by

ssss23232023
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

WEB BROWSER = Web browser is software program to navigate the web pages on the internet.

Examples - Google Chrome , Mozilla Firefox, Internet Explorer etc.


WEB HOSTING WEB SERVER
Web hosting is the process of uploading/saving the A web server is a computer or a group of computers
web content on a web server to make it available on that hosts or stores content of website.
WWW (World Wide Web). Examples – Apache Tomcat , IIS
Web 2.0 =Web 2.0 refers to new generation of dynamic and interactive websites.
HTML (Hyper Text Markup Language) XML(eXtensible Markup Language)
HTML is used to display the data, text and XML is used to describe the data and focus is on
images of a webpage on web browser and focus the content of the data. XML is recommended by
is on the format of data displayed. the World Wide Web Consortium (W3C). It is a
free open standard.
HTML tags are predefined XML tags are not predefined. We can create our
own tags. XML code can also contain HTML tags.
HTML tags are not case sensitive. Example - XML tags are case-sensitive
<HTML> or <html> are the same

URL (Uniform Resource Locator) DOMAIN NAME


URL is unique identifier of a web page Domain name is your website name
The most general form of a URL syntax is as follows:
Protocol:// <domain name> / <directory path>/<object name>
For example - [Link]
( Domain Name System / Domain Name Resolution - when the user types a domain name, the
domain names are translated into Internet Protocol (IP) addresses. The computers or machines, access
websites based on IP addresses )

UNIT III – DATABASE MANGEMENT (20 Marks )


A DBMS or database management system is Database = Collection of inter-related tables and
a software used to create and manage other objects.
databases.
{manage = insert new records, display, DBMS = DB + MS ,
modify, delete , provide access control etc. } DataBase + software to handle the DB
RDBMS = RDBMS = database is Examples of popular RDBMS –
Relational Database organised in the form of MySQL, Oracle, Sybase, DB2
Management System relations (i.e. tables)
TERMINOLGY ( RDBMS) [1 mark / 2marks ]
Table : CUSTOMER
Cust_Id CNAME AADHAR_NO ADDRESS PHONE
C01 ANUJ KUMAR 345612348912 GAUTAM VIHAR 8765432190
CO3 NEHA SINGH 367823458904 RANI BAGH 7722334673
CO4 NAREN GARG 453627980423 MAHESH NAGAR 6345612566
CO7 BHARAT VERMA 516782245679 MALVIYA NAGAR 9818624567
Primary Key - An attribute or Candidate Key- An attribute Alternate Key - The candidate
set of attributes that uniquely or set of attributes that can key which is not chosen as
identify a record in a become primary key of the primary key
table/relation table/relation
e.g. - in table customer(cust_id, e.g. - customer(cust_id, cname, e.g. in table customer(cust_id,
cname, aadhar_no, address, aadhar_no, address, phone) , cname, aadhar_no, address,
phone) , the attribute cust_id is the attribute cust_id and phone) , the attribute cust_id is
primary key aadhar_no are candidate keys chosen as primary key,
then aadhar_no will be
alternate key

18 | K V S – R e g i o n a l O f f i c
Foreign Key - A non-key e.g – Customer.cust_id =
attribute of a table whose Table Customer(cust_id, primary key
values are derived from cname , address, phone) Orders.cust_id =
primary key of some other table foreign key
is known as foreign key in Table Orders (Order_id,
current table. order_dt , cust_id , amount)

Database = Collection of inter-related tables and other objects.


Relation /Table = collection of inter-related records
Tuple /Row/ Record = collection of attributes
Attribute/Column / Field = descriptive property of an entity
Data item = value

SQL = Structured Query SQL = Open industry standard MySQL = Open Source RDBMS
Language language used to query (Michael Widenius aka Monty =
(pronounced as = SEEQUEL) ( create and manage) Chief Inventor)
databases
DATATYPES COMMONLY USED IN SQL –
For Text Numeric Data Date Boolean values
CHAR ( n ) VARCHAR ( n ) INT ( n ) or DECIMAL( n, Date tinyint(1)
INTEGER ( n ) d) ( value = 0
or format means False , 1
FLOAT (n) ‘yyyy-dd-mm’ means True)
decimal(n,d) = n is total number of digits and d is no of digits after decimal
example - decimal(7,2) => total 7 digits of number ( 5+ 2 decimal part)

Advantages of SQL [1 mark / 2 marks ]


Faster Query Processing ; User-friendly language , no coding skills necessary ; Standardised
Language with uniform platform ; Interactive ; Portable
Categories of SQL Commands [1 mark / 2 marks ]
DDL = Data Definition DML = Data Manipulation DCL = Data Control TCL = Transaction
Language Language Language Control Language
Used to create/modify Used to change table data
table structure
( CREATE , ALTER , ( INSERT, UPDATE, (GRANT, REVOKE) ( COMMIT, ROLLBACK,
DROP etc) SELECT, DELETE etc) SAVEPOINT)

SQL Commands at a glance [1 mark / 2 marks ]


1 - CREATE DATABASE = to create tables and create database <database-name> ;
work with them
2 – VIEW LIST OF EXISTING DATABASES ON show databases ;
YOUR MACHINE =
3 – OPEN A DATABASE FOR WORK = use <database-name> ;
4 – VIEW LIST OF EXISTING TABLES AND / show tables ;
OR VIEWS =
5 – VIEW THE STRUCTURE OF AN EXISTING desc <table-name> ; OR
TABLE = describe <table-name> ;
6 - CREATE TABLE ( DDL command )=
CREATE TABLE <table-name> CREATE TABLE PUPIL
( <col1-name> datatype [(size)] [constraint] , ( admno integer(4) primary key ,
<col2-name> datatype[(size)] [constraint] , name varchar(18) not null,

19 | K V S – R e g i o n a l O f f i c e
- - - - - ); dob date , gender char(6) DEFAULT 'MALE',
fees decimal ( 7, 2) , avgmark decimal(5,2) ) ;
7 - INSERT Records ( DML Command )= Two ways of using insert command ( A and B) :
A = INSERT INTO <table-name> VALUES B = INSERT INTO <table-name> (<col1-name> ,
(<value-1> , <value-2> , - - - ) ; <col2-name> , - - -)
- - order of data-values same as table structure VALUES (<col1-value> , <col2-value> , - - - ) ;
i.e. columns order - - useful when inserting partial record or
change the order of insertion
- - 'string' or "string" , date as 'yyyy-mm-dd' - - non-numeric data in 'quotes'
as per A= as per B =
insert into pupil values(114, 'ANITA MATHUR', insert into pupil(name, admno, dob)
'2002-06-20' , 'FEMALE', 3150.0 , 91.2) ; values('DEV SHARMA', 112, '2003-01-03') ;

8 ALTER TABLE ( DDL command)-


- to add a column
ALTER TABLE <table-name> ADD <col-name> <datatype>[(<size>)] [constraint] ;

e.g. - ALTER TABLE pupil ADD grade char(2);

- to add a column with default


ALTER TABLE <table-name> ADD <col-name> <datatype>default data] ;
e.g. - ALTER TABLE pupil ADD Conduct DEFAULT”GOOD”;

- to add integrity constraint


ALTER TABLE <table-name> ADD <constraint> (<col-name>);

- to redefine a column (datatype , size, default-value)


ALTER TABLE <TABLE-NAME>
MODIFY (<COL-NAME> NEWdatatype [(<size>)] ) [ FIRST | AFTER colname] ;
Example - ALTER TABLE PUPIL Modify name varchar(20);
to renaming a column
ALTER TABLE <TABLE-NAME>
MODIFY <old_col_name> <new_col_name > < new_col_definition> ;

- to delete a column

e.g. - ALTER TABLE pupil DROP grade ;


ALTER TABLE <table-name> DROP <col-name> ;

9- DROP COMMAND –
(DDL command)
To delete a table as well as its structure fromdatabase.
DROP TABLE <table-name> ;
DROP TABLE FLIGHT ;
OR
DROP TABLE [IF EXISTS] <table-name> ;
DROP is also used as a CLAUSE in ALTER
TABLE command
ALTER TABLE book DROP disc_amt ;
ALTER TABLE flight DROP PRIMARY KEY ;
TABLE : PUPIL
Admno Name DOB Gender Fees Avgmark Grade
104 RAVINDER 2004-02-24 MALE 3150.0 85.6 B
107 PARTH GUPTA 2003-07-15 MALE 2850.0 90.3 A
112 DEV SHARMA 2003-09-03 MALE 300.0 NULL C
114 ANITA MATHUR 2003-06-20 FEMALE 3150.0 92.7 NULL
122 NAVNEET 2004-03-10 MALE 2850.0 87.5 B
126 GEETU VERMA 2003-11-16 FEMALE 2700.0 91.4 A
128 PREETI 2004-01-13 FEMALE 3000.0 93.6 A
10- UPDATE Query (DML Command) - To modify existing record(s)
UPDATE <table-name> update pupil
SET <col-name> = <value> [ , <col2-name> = set avgmark = 89.7 , grade = 'B'
<value> , - - - ] where admno = 107 or admno = 112 ;
[WHERE <condition>] ;
11- DELETE Query (DML Command )- To remove a record(S)
DELETE FROM <table-name> [ WHERE <condition> ] ;
Example - delete from pupil where admno = 126 ;
12- SELECT Query (DML Command) - to view data (content) of a table / view

General syntax - ( In the commands the keywords are written in


SELECT <col-list> CAPITALS so that they are easy to identify.
FROM <table-name> [ ,<table2-name> , - - - ] Otherwise SQL commands are NOT CASE
SENSITIVE. One can type in small-case or upper-
[WHERE <condition> ]
case )
[ ORDER BY ASC | DESC ]
[ GROUP BY <col-name> [ HAVING <condition-
based-on-group-col> ] ] ;
Examples - There are many ways of using SELECT
Command
select admno , dob , name from pupil ; select name , 'was born on' , dob from pupil ;
select * from pupil ; select name , dob AS "Date of Birth" from pupil ;

Column ALIAS NAME – keyword AS used. select admno, name, dob AS BIRTHDATE from
<col_name> AS <alias-name> pupil ;

20 | K V S – R e g i o n a l O f f i c e ,
USE “ ” or ‘ ‘ (quotes) if alias name is more than (in above examples, column alias BIRTHDATE ,
one word long “Date of Birth” have been used in order by
clause)
Following are the clauses/operators which can be used with SELECT command:
DISTINCT - Used to display distinct values select DISTINCT name from pupil;
from a column of a table. To view data of names (without repetition) of
the students
WHERE - Used to specify the condition based OPERATORS USED IN WHERE CLAUSE -
on which rows of a table are displayed > , < , < = , = , != , AND (&&) , OR (||), NOT
To view name, dob, grade of students with ‘B’ select name, dob, grade from pupil
grade. WHERE grade = ‘B’ ;
To view data of admission number 126 SELECT * FROM pupil WHERE admno = 126 ;
To view name, admission number and select name , admno , dob
date_of_birth of those students who have fees from pupil
more than 3000 where fees > 3000 ;
BETWEEN - Used to define the range of values Range includes both the upper and the lower
within which the column values must fall to values.
make a condition true. select * from pupil where fees BETWEEN 3000
AND 3500 ;
Same command using AND , relational select * from pupil
operators where fees >= 3000 AND fees <= 3500 ;
IN - Used to select values that match any value select admno, name from pupil
in a list of Specified values where name IN ( ‘RAVINDER’ , ‘NAVNEET ‘ ) ;
Same command using OR operator select admno, name from pupil
where name = ‘RAVINDER’ name = ‘NAVNEET ‘ ;
LIKE - Used for pattern matching of string data % = zero, one or many characters
using wildcard characters % and _ _ = single character (underscore symbol)
To view data from pupil for names begin with select * from pupil where name LIKE ‘P%’ ;
letter ‘P’
To view details of those students whose fees is select * from pupil
more than 3000 and name ends with ‘R’ where fees > 3000 AND name LIKE ‘%R’ ;
‘A%’ = the string begins with character ‘A’ (I have typed space in between underscore
‘_ _a%’ = the third character is ‘a’ character to show clarity, it is typed in
‘_ _ a’ = any three letter string that ends in ‘a’ continuity in the actual command)
‘ ___ ’ = Any four letter string
select * from pupil where name LIKE ‘A%’ select empno , ename, salary+comm AS
ORDER BY name ; “TOTAL_PAY” from employee
where name LIKE ‘R%’ ORDER BY total_pay ;
IS NULL / IS NOT NULL - Used to select rows in which the specified
column is NULL (or IS NOT NULL)
To view the details of those students whose select * from pupil where dob IS NULL ;
dob is not entered / dob datavalue is not
available.
ORDER BY - Used to display the selected rowsin by default the ORDER is ASC i.e. ascending order.
ascending or in descending order of the For descending order, must specify DESC
specified column/expression

22 | K V S – R e g i o n a l O f f i c e
select * from pupil ORDER BY name ; select admno, dob, name, grade from pupil
OR ORDER BY name DESC ;
select * from pupil ORDER BY name ASC ; select * from pupil
ORDER BY grade , name DESC ;
(NOTICE two columns in order by, here Col1 –
ASC, Col2-DESC)
GROUP BY – To apply a SQL SELECT query on A group column is generally that column of the
a group of records instead of whole table. table which has repeating values.
GROUP BY <column-name> is used
For example, columns fees, gender , grade in select gender, count(*) from pupil
table pupil have repeating values – you can GROUP BY gender ;
group the values of these columns. select max(fees) from pupil GROUP By grade ;
Avoid non-group function or non-group Group functions ignore NULL values.
column in SELECT clause.
Look a t ORDER BY AND GRO UP BY again –
Order by Group by

HAVING - To add condition to GROUP BY select grade, avg(marks) from pupil


column. ( i.e. Use only with Group By ) group by grade HAVING count(*) > 1 ;
AGGREGATE FUNCTIONS (Also known as Group/ Multi-Row Functions) [ 1 / 2 marks – output)
SUM() Returns the sum of the column
MIN() Returns the minimum value in the given column or set of values
MAX() Returns the maximum in the given column or set of values
AVG() Returns the average value of data in the given column or set of values
COUNT() Returns the total number of values / records as per the given column

WORKING WITH MORE THAN ONE TABLE - [1 / 2 mark – query ]


CARTESIAN PRODUCT OR CROSS JOIN Cross Join of two tables is obtained by pairing
up each row of one table with each row of the
other table.

22 | K V S – R e g i o n a l O f f i c e

You might also like