SQL Commands & Mongo DB New Syllabus

Similar documents
Chapter 13 : Informatics Practices. Class XI ( As per CBSE Board) SQL Commands. New Syllabus Visit : python.mykvs.in for regular updates

Chapter 9: Working with MySQL

Private Institute of Aga NETWORK DATABASE LECTURER NIYAZ M. SALIH

Relation Databases. By- Neha Tyagi PGT CS KV 5 Jaipur II Shift Jaipur Region. Based on CBSE Curriculum Class -11. Neha Tyagi, PGT CS II Shift Jaipur

CGS 3066: Spring 2017 SQL Reference

SQL language. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c)

Chapter-14 SQL COMMANDS

How to use SQL to create a database

DATABASES SQL INFOTEK SOLUTIONS TEAM

MySQL. Prof.Sushila Aghav

Relational databases and SQL

Chapter # 7 Introduction to Structured Query Language (SQL) Part I

STRUCTURED QUERY LANGUAGE (SQL)

Downloaded from

tablename ORDER BY column ASC tablename ORDER BY column DESC sortingorder, } The WHERE and ORDER BY clauses can be combined in one

GridDB Advanced Edition SQL reference

Visit for more.

Relational Database Language

CS6312 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C

Simple Quesries in SQL & Table Creation and Data Manipulation

Oral Questions and Answers (DBMS LAB) Questions & Answers- DBMS

INDEX. 1 Basic SQL Statements. 2 Restricting and Sorting Data. 3 Single Row Functions. 4 Displaying data from multiple tables

Chapter 1 SQL and Data

RDBMS-Day3. SQL Basic DDL statements DML statements Aggregate functions

SQL. Structured Query Language

Chapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

G64DBS Database Systems. Lecture 7 SQL SELECT. The Data Dictionary. Data Dictionaries. Different Sections of SQL (DDL) Different Sections of SQL (DCL)

Introduction to SQL on GRAHAM ED ARMSTRONG SHARCNET AUGUST 2018

ACS-3902 Fall Ron McFadyen 3D21 Slides are based on chapter 5 (7 th edition) (chapter 3 in 6 th edition)

Today Learning outcomes LO2


Course Outline. MySQL Database Administration & Design. Course Description: Pre-requisites: Course Content:

Index. Bitmap Heap Scan, 156 Bitmap Index Scan, 156. Rahul Batra 2018 R. Batra, SQL Primer,

MySQL Introduction. By Prof. B.A.Khivsara

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL)

WHAT IS SQL. Database query language, which can also: Define structure of data Modify data Specify security constraints

1) Introduction to SQL

ASSIGNMENT NO 2. Objectives: To understand and demonstrate DDL statements on various SQL objects

Chapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel

SQL Fundamentals. Chapter 3. Class 03: SQL Fundamentals 1

Introduction to Databases and SQL

INTRODUCTION TO DATABASE

Institute of Aga. Network Database LECTURER NIYAZ M. SALIH

INFORMATION TECHNOLOGY NOTES

After completing this unit, you should be able to: Define the terms

CS 327E Lecture 2. Shirley Cohen. January 27, 2016

Downloaded from

HKTA TANG HIN MEMORIAL SECONDARY SCHOOL SECONDARY 3 COMPUTER LITERACY. Name: ( ) Class: Date: Databases and Microsoft Access

EE221 Databases Practicals Manual

Oracle Database 10g Express

Information Systems Engineering. SQL Structured Query Language DDL Data Definition (sub)language

Introduction to SQL. IT 5101 Introduction to Database Systems. J.G. Zheng Fall 2011

Course Outline and Objectives: Database Programming with SQL

COGS 121 HCI Programming Studio. Week 03 - Tech Lecture

Chapter 14: MySQL Revision Tour. Informatics Practices Class XII. By- Rajesh Kumar Mishra. KV No.1, AFS, Suratgarh (Raj.)

Lab # 4. Data Definition Language (DDL)

Database Foundations. 6-3 Data Definition Language (DDL) Copyright 2015, Oracle and/or its affiliates. All rights reserved.

Database Management System 9

CMP-3440 Database Systems

Institute of Aga. Microsoft SQL Server LECTURER NIYAZ M. SALIH

Exam code: Exam name: Database Fundamentals. Version 16.0

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

Chapter 4. Basic SQL. SQL Data Definition and Data Types. Basic SQL. SQL language SQL. Terminology: CREATE statement

SQL: Concepts. Todd Bacastow IST 210: Organization of Data 2/17/ IST 210

Sql Server Syllabus. Overview

MySQL Introduction. By Prof. B.A.Khivsara

Deepak Bhinde PGT Comp. Sc.

TINYINT[(M)] [UNSIGNED] [ZEROFILL] A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.

SQL. Char (30) can store ram, ramji007 or 80- b

Unit 1 - Chapter 4,5

Chapter 1 An introduction to relational databases and SQL

1. Using Bitvise SSH Secure Shell to login to CS Systems Note that if you do not have Bitvise ssh secure shell on your PC, you can download it from

Databases and SQL programming overview

UNIT-IV (Relational Database Language, PL/SQL)

Structured Query Language (SQL)

Database Systems Fundamentals

Databases and MySQL: The Basics

Careerarm.com. 1. What is MySQL? MySQL is an open source DBMS which is built, supported and distributed by MySQL AB (now acquired by Oracle)

SQL Functionality SQL. Creating Relation Schemas. Creating Relation Schemas

SQL Data Definition Language: Create and Change the Database Ray Lockwood

Creating and Managing Tables Schedule: Timing Topic

1Z Oracle Database 11g - SQL Fundamentals I Exam Summary Syllabus Questions

Oracle Exam 1z0-882 Oracle Certified Professional, MySQL 5.6 Developer Version: 7.0 [ Total Questions: 100 ]

Database design process

Introduction to Databases. MySQL Syntax Guide: Day 1

3.1. Keys: Super Key, Candidate Key, Primary Key, Alternate Key, Foreign Key

MariaDB Crash Course. A Addison-Wesley. Ben Forta. Upper Saddle River, NJ Boston. Indianapolis. Singapore Mexico City. Cape Town Sydney.

Brief History of SQL. Relational Database Management System. Popular Databases

Chapter 4: SQL Basics

Relational Data Structure and Concepts. Structured Query Language (Part 1) The Entity Integrity Rules. Relational Data Structure and Concepts

SQL functions fit into two broad categories: Data definition language Data manipulation language

Jarek Szlichta

Database Foundations. 6-4 Data Manipulation Language (DML) Copyright 2015, Oracle and/or its affiliates. All rights reserved.

UNIT III INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL)

Business Analytics. SQL PL SQL [Oracle 10 g] P r i n c e S e t h i w w w. x l m a c r o. w e b s. c o m

Alper VAHAPLAR

Module 3 MySQL Database. Database Management System

Unit 7: Database Development (Basic)

COSC344 Database Theory and Applications. Lecture 5 SQL - Data Definition Language. COSC344 Lecture 5 1

Introduction to Computer Science and Business

Transcription:

Chapter 15 : Computer Science Class XI ( As per CBSE Board) SQL Commands & Mongo DB New Syllabus 2018-19

SQL SQL is an acronym of Structured Query Language.It is a standard language developed and used for accessing and modifying relational databases. The SQL language was originally developed at the IBM research laboratory in San José, in connection with a project developing a prototype for a relational database management system called System R in the early 70s. SQL is being used by many database management systems. Some of them are: MySQL PostgreSQL Oracle SQLite Microsoft SQL Server

MySQL is currently the most popular open source database software. It is a multi-user, multithreaded database management system. MySQL is especially popular on the web. It is one of the parts of the very popular LAMP platform. Linux, Apache, MySQL and PHP or WIMP platform Windows,Apache,MySQL and PHP. MySQL AB was founded by Michael Widenius (Monty), David Axmark and Allan Larsson in Sweden in year 1995.

MySQL Features Open Source & Free of Cost: It is Open Source and available at free of cost. Portability: Small enough in size to instal and run it on any types of Hardware and OS like Linux,MS Windows or Mac etc. Security : Its Databases are secured & protected with password. Connectivity Various APIs are developed to connect it with many programming languages. Query Language It supports SQL (Structured Query Language) for handling database.

Types of SQL Commands DDL (Data Definition Language) To create database and table structure-commands like CREATE, ALTER, DROP etc. DML (Data Manipulation Language) Record/rows related operations.commands like SELECT..., INSERT..., DELETE..., UPDATE... etc. DCL (Data Control Language) Used to control the transactions.commands like COMMIT, ROLLBACK, SAVEPOINT etc. Transactional control Language. used to manipulate permissions or access rights to the tables.commands like GRANT, REVOKE etc.

MySql datatypes numeric decimal -decimal(<precision>, [<scale>]) [zerofill] For storing floating-point numbers where precision is critical. Int - int(<size>) [auto_increment] [unsigned] [zerofill] A whole number, 4 bytes, with a maximum range of -2,147,483,648 to 2,147,483,647 (unsigned: 0 to 4,294,967, 295) string char-char(<size>) [binary] Fixed length for storing strings that won't vary much in size. Range of 0 to 255, stores that amount in bytes Varchar-varchar(<size>) [binary] Variable length for storing strings that will vary in size. Range of 0 to 255, stores that amount in bytes, plus 1 byte date Date-Format: YYYY-MM-DD,Example: 2006-09-23,Range of years 1000 to 9999

Getting listings of database and tables mysql> SHOW DATABASES; mysql> SHOW TABLES; Creating a databasemysql> CREATE database myschool; Deleting a database mysql> DROP database abc; database;to remove table mysql> drop table abctable; After we have created the database we use the USE statement to change the current mysql> USE myschool; Creating a table in the database is achieved with CREATE table statement. mysql> CREATE TABLE student (lastname varchar(15),firstname varchar(15), city varchar(20), class char(2)); The command DESCRIBE is used to view the structure of a table. mysql> DESCRIBE student;

To insert new rows into an existing table use the INSERT command: mysql>insert INTO student values( dwivedi, freya, Udaipur, 4 ); Similarly we can insert multiple records.with the SELECT command we can retrieve previously inserted rows: mysql> SELECT * FROM student; Selecting rows by using the WHERE clause in the SELECT command mysql> SELECT * FROM student WHERE class= 4"; Selecting specific columns(projection) by listing their names mysql> SELECT first_name, class FROM student; To modify or update entries in the table use the UPDATE command mysql> UPDATE student SET class= V" WHERE firstname= freya";

Deleting selected rows from a table using the DELETE command mysql> DELETE FROM student WHERE firstname= amar"; A general form of SELECT is: SELECT what to select(field name) FROM table(s) WHERE condition that the data must satisfy; Comparison operators are: < ; <= ; = ;!= or <> ; >= ; > Logical operators are: AND ; OR ; NOT Comparison operator for special value NULL: IS mysql> SELECT * FROM Student WHERE City IS NULL ;

Pattern Matching LIKE Operator A string pattern can be used in SQL using the following wild card % Represents a substring in any length _ Represents a single character Example: A% represents any string starting with A character. A represents any 3 character string ending with A. _B% represents any string having second character B _ represents any 3 letter string. A pattern is case sensitive and can be used with LIKE operator. mysql> SELECT * FROM Student WHERE Name LIKE A% ; mysql> SELECT * FROM Student WHERE Name LIKE%Singh% ; mysql> SELECT Name, City FROM Student WHERE Class>=8 AND Name LIKE %Kumar% ;

Ordering Query Result ORDER BY Clause A query result can be orders in ascending (A-Z) or descending (Z-A) order as per any column. Default is Ascending order. mysql> SELECT * FROM Student ORDER BY class; To get descending order use DESC key word. mysql> SELECT * FROM Student ORDER BY class DESC;

Creating Table with Constraints The following constraints are commonly used in SQL: NOT NULL -It Ensures that a column cannot have a NULL value UNIQUE - It Ensures that all values in a column are different PRIMARY KEY - A combination of a NOT NULL and UNIQUE. Uniquely identifies each row in a table FOREIGN KEY - It Uniquely identifies a row/record in another table CHECK - It Ensures that all values in a column satisfies a specific condition DEFAULT - It Sets a default value for a column when no value is specified INDEX - It is Used to create and retrieve data from the database very quickly

Creating Table with Constraints mysql> CREATE TABLE Persons ( ID int NOT NULL PRIMARY KEY, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int, City varchar(255) DEFAULT Jaipur', CONSTRAINT CHK_Person CHECK (Age>=18) ); mysql> CREATE TABLE Orders ( OrderID int NOT NULL, OrderNumber int NOT NULL, PersonID int, PRIMARY KEY (OrderID), FOREIGN KEY (PersonID) REFERENCES Persons(ID) );

MySQL - INDEXES Indexes are used to retrieve data from the database very fast. The users cannot see the indexes, they are just used to speed up searches/queries. The INSERT and UPDATE statements take more time on tables having indexes, whereas the SELECT statements become fast on those tables. The reason is that while doing insert or update, a database needs to insert or update the index values as well. CREATE INDEX Creates an index on a table. Duplicate values are allowed: mysql> CREATE INDEX idx_lastname ON Persons (LastName);

MySQL INDEXES CREATE UNIQUE INDEX Creates a unique index on a table. Duplicate values are not allowed: mysql> CREATE UNIQUE INDEX idx_lastname ON Persons (LastName); DROP INDEX Statement The DROP INDEX statement is used to delete an index in a table. mysql> ALTER TABLE table_name DROP INDEX index_name;

MySQL JOINS In MySQL JOINS are used with SELECT statement. It is used to retrieve data from multiple tables. There are three types of MySQL joins: 1. MySQL INNER JOIN (or sometimes called simple join) 2. MySQL LEFT OUTER JOIN (or sometimes called LEFT JOIN) 3. MySQL RIGHT OUTER JOIN(or sometimes called RIGHT JOIN)

1. MySQL Inner JOIN (Simple Join) It return all rows from multiple tables where the join condition is satisfied. mysql> SELECT columns FROM table1 INNER JOIN table2 ON table1.column = table2.column;

2. MySQL Left Outer Join It returns all rows from the left hand table specified in the ON condition and only those rows from the other table where the join condition is fulfilled. mysql> SELECT columns FROM table1 LEFT JOIN table2 ON table1.column = table2.column;

2. MySQL Right Outer Join It returns all rows from the right hand table specified in the ON condition and only those rows from the other table where the join condition is fulfilled. mysql> SELECT columns FROM table1 RIGHT JOIN table2 ON table1.column = table2.column;

Mongo DB Mongodb is a document-oriented NoSQL database used for high volume data storage. It is an open source product, developed and supported by a company named 10gen. It was designed to work with commodity servers. Now it is used by company of all sizes, across all industry. Main purpose to build MongoDB: Scaling from single server deployments to large Performance High Availability Scalability

Mongo DB MongoDB Advantages MongoDB is schema less There may be difference between number of fields, content and size of the document from one to other. Structure of a object is clear in MongoDB. no complex joins in MongoDB. It is very easy to scale. It uses internal memory for storing working sets that s why its access data fast. It is easy to use It is Light Weight Much Faster than RDBMS

Mongo DB Download & Install MongoDB on Windows Step 1) Double click mongodb<version>.exe file, which can be downloaded from the MongoDB website or from https://www.mongodb.org/dl/win32/i386 Below are the steps for 64 bit version. Step 2) click next->next-> Step 3) Click on the "complete" button to install all of the components. Step 4) Click on the Install button to start the installation. Step 5) Click on the Finish button to complete the installation.

Mongo DB MongoDB Datatypes Data Types Description Null Used to store null values. Boolean Used to store boolean values. Integer Used to store the numeric value. It can be 32 bit or 64 bit depending on the server we are using. Double Used to store floating point values. String Used to store Text. It must be UTF 8. Arrays Used to store a list or multiple values. Object Used for embedded documents. Symbol Used for specific type symbol. Date Used to stores the current date or time.

Mongo DB Open the the shell through command prompt. Creating a database C:\mongodb\bin\>use employee Creating a collection using insert() C:\mongodb\bin\> db.employee.insert ( { "Employeeid" : 1, "EmployeeName" : freya" } ) MongoDB Query Document using find() C:\mongodb\bin\> db.employee.find({employeename : freya"}).foreach(printjson);