SlideShare a Scribd company logo
Database Architecture and Basic
          Concepts
            What is Database?
       Structured Query Language
           Stored Procedures
What is Database?
 A database is an object for storing complex, structured
  information.
 What make database unique is the fact that databases are
  design to retrieve data quickly.
 Database samples such as Access and SQL Server called
  database management systems (DBMS).
 To access the data stored in the database and to update the
  database, you use a special language, Structure Query
  Language (SQL).
Continue…
 Relational Databases
Continue…
Structure Query Language
 SQL (Structured Query Language) is a universal language for
  manipulating tables, and every database management system
  (DBMS) supports it.

 SQL is a nonprocedural language.


 SQL statements are categorized into two major categories:
   Data Manipulation Language (DML)
   Data Definition Language (DDL)
Continue…
 Executing SQL Statements.
   Opening Microsoft SQL Server Management Studio
   Using New Query Windows.
Continue…
 Selection Queries
   The simplest form of the SELECT statement is


   SELECT fields
   FROM tables

   where fields and tables are comma-separated lists of the fields you want
   to retrieve from the database
   and the tables they belong to.
 WHERE Clause
  To restrict the rows returned by the query, use the WHERE clause
  of the SELECT statement. The most common form of the SELECT statement is
     the following:
  SELECT fields
  FROM tables
  WHERE condition
  The fields and tables arguments are the same as before.

 Sample:
 SELECT ProductName, CategoryName
 FROM Products
 WHERE CategoryID In (2, 5,6,10)
 TOP Keyword
   Some queries may retrieve a large number of rows, while
    you‟re interested in the top few rows only.
   The TOP N keyword allows you to select the first N rows and
    ignore the remaining ones.
 DISTINCT Keyword
   The DISTINCT keyword eliminates any duplicates from the
    cursor retrieved by the SELECT statement.
 SELECT DISTINCT Country
 FROM Customers
 ORDER Keyword
   The rows of a query are not in any particular order. To request
    that the rows be returned in a specific order, use the
    ORDER BY clause, whose syntax is
           ORDER BY col1, col2, . . .

            SELECT CompanyName, ContactName
                    FROM Customers
                 ORDER BY Country, City
 SQL Join
   Joins specify how you connect multiple tables in a query, and there are four types
      of joins:
           Left outer, or left join
           Right outer, or right join
           Full outer, or full join
           Inner join


    Left Joins
      This join displays all the records in the left table and only those records of the
      table on the right that match certain user-supplied criteria. This join has the
      following syntax:
      FROM (primary table) LEFT JOIN (secondary table) ON (primary table).(field)
      (comparison) (secondary table).(field)
          SELECT title, pub_name
          FROM titles LEFT JOIN publishers
          ON titles.pub_id = publishers.pub_id
 Right Joins
  This join is similar to the left outer join, except that all rows in the table on the right
  are displayed and only the matching rows from the left table are displayed. This join has
  the following syntax:
  FROM (secondary table) RIGHT JOIN (primary table) ON (secondary table).(field)
  (comparison) (primary table).(field)

  “SELECT title, pub_name
  FROM titles RIGHT JOIN publishers
  ON titles.pub_id = publishers.pub_id”

 Full Joins
  The full join returns all the rows of the two tables, regardless of whether there are
  matching rows or not. In effect, it‟s a combination of left and right joins.

   “SELECT title, pub_name
   FROM titles FULL JOIN publishers
   ON titles.pub_id = publishers.pub_id”
 Inner Joins
  This join returns the matching rows of both tables, similar to the WHERE clause, and has
  the following syntax:
  FROM (primary table) INNER JOIN (secondary table) ON (primary table).(field)
  (comparison) (secondary table).(field)

“SELECT titles.title, publishers.pub_name FROM titles, publishers
              WHERE titles.pub_id = publishers.pub_id”

                                        Or

                “SELECT titles.title, publishers.pub_name
    FROM titles INNER JOIN publishers ON titles.pub_id =
                    publishers.pub_id”
 Grouping Rows
  Sometimes you need to group the results of a query, so that you
   can calculate subtotals.
      SELECT ProductID,
           SUM(Quantity * UnitPrice *(1 - Discount))
           AS [Total Revenues]
      FROM [Order Details]
      GROUP BY ProductID
      ORDER BY ProductID
 Action Queries
   Execute queries that alter the data in the database‟s tables.
   There are three types of actions you can perform against a database:
    1.   Insertions of new rows (INSERT)
    2.   Deletions of existing rows (DELETE)
    3.   Updates (edits) of existing rows (UPDATE)

   Deleting Rows
        The DELETE statement deletes one or more rows
        from a table, and its syntax is:
        DELETE table_name WHERE criteria

                                 “DELETE Orders
                           WHERE OrderDate < „1/1/1998‟ ”
 Inserting New Rows
      The syntax of the INSERT statement is:

      INSERT table_name (column_names) VALUES (values)

  column_names and values are comma-separated lists of columns and their respective values.

“INSERT Customers (CustomerID, CompanyName) VALUES („FRYOG‟, „Fruit &
                                Yogurt‟)”

                                           Or

                     “INSERT INTO SelectedProducts
        SELECT * FROM Products WHERE CategoryID = 4”
 Editing Existing Rows
 The UPDATE statement edits a row‟s fields, and its syntax is

 UPDATE table_name SET field1 = value1, field2 = value2,
 … WHERE criteria

   “UPDATE Customers SET Country=‟United Kingdom‟
              WHERE Country = „UK‟ “
SQL SUMMARY
EXECUTED STATEMENT
Client/server architecture
Stored Procedures
 Stored procedures are short programs that are executed on the server and
  perform very specific tasks.
 Any action you perform against the database frequently should be coded
  as a stored procedure, so that you can call it from within any application
  or from different parts of the same application.
 Benefit:
    Stored procedures isolate programmers from the database and minimize the
     risk of impairing the database‟s integrity.
    You don‟t risk implementing the same operation in two different ways.
    Using stored procedures is that they‟re compiled by SQL Server and they‟re
     executed faster.
    Stored procedures contain traditional programming statements that allow
     you to validate arguments, use default argument values, and so on.
 The language you use to write stored procedure is called T-SQL, and it‟s
  a superset of SQL.
ALTER PROCEDURE dbo.SalesByCategory
   @CategoryName nvarchar(15),
   @OrdYear nvarchar(4) = „1998‟
AS
IF @OrdYear != „1996‟ AND @OrdYear != „1997‟ AND @OrdYear != „1998‟
BEGIN
   SELECT @OrdYear = „1998‟
END
SELECT ProductName,
   TotalPurchase = ROUND(SUM(CONVERT(decimal(14,2),
   OD.Quantity * (1-OD.Discount) * OD.UnitPrice)), 0)
FROM [Order Details] OD, Orders O, Products P, Categories C
WHERE OD.OrderID = O.OrderID
   AND OD.ProductID = P.ProductID
   AND P.CategoryID = C.CategoryID
   AND C.CategoryName = @CategoryName
   AND SUBSTRING(CONVERT(nvarchar(22), O.OrderDate, 111), 1, 4) = @OrdYear
GROUP BY ProductName
ORDER BY ProductName

More Related Content

What's hot

Chapter 4 Structured Query Language
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
Eddyzulham Mahluzydde
 
Oracle SQL Basics
Oracle SQL BasicsOracle SQL Basics
Oracle SQL Basics
Dhananjay Goel
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
Ehsan Hamzei
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
Pongsakorn U-chupala
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
Hammad Rasheed
 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)
Punjab University
 
Sql Tutorials
Sql TutorialsSql Tutorials
Sql Tutorials
Priyabrat Kar
 
SQL
SQLSQL
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
Shrija Madhu
 
Sql server T-sql basics ppt-3
Sql server T-sql basics  ppt-3Sql server T-sql basics  ppt-3
Sql server T-sql basics ppt-3
Vibrant Technologies & Computers
 
MYSQL - PHP Database Connectivity
MYSQL - PHP Database ConnectivityMYSQL - PHP Database Connectivity
MYSQL - PHP Database Connectivity
V.V.Vanniaperumal College for Women
 
Sql commands
Sql commandsSql commands
Sql commands
Pooja Dixit
 
SQL
SQLSQL
Sql – Structured Query Language
Sql – Structured Query LanguageSql – Structured Query Language
Sql – Structured Query Languagepandey3045_bit
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
Ram Kedem
 
SQL - RDBMS Concepts
SQL - RDBMS ConceptsSQL - RDBMS Concepts
SQL - RDBMS Concepts
WebStackAcademy
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
Smriti Jain
 

What's hot (20)

Sql.pptx
Sql.pptxSql.pptx
Sql.pptx
 
Chapter 4 Structured Query Language
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
 
Oracle SQL Basics
Oracle SQL BasicsOracle SQL Basics
Oracle SQL Basics
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)
 
Sql Tutorials
Sql TutorialsSql Tutorials
Sql Tutorials
 
SQL
SQLSQL
SQL
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 
Sql server T-sql basics ppt-3
Sql server T-sql basics  ppt-3Sql server T-sql basics  ppt-3
Sql server T-sql basics ppt-3
 
MYSQL - PHP Database Connectivity
MYSQL - PHP Database ConnectivityMYSQL - PHP Database Connectivity
MYSQL - PHP Database Connectivity
 
Sql commands
Sql commandsSql commands
Sql commands
 
SQL
SQLSQL
SQL
 
Sql – Structured Query Language
Sql – Structured Query LanguageSql – Structured Query Language
Sql – Structured Query Language
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
SQL - RDBMS Concepts
SQL - RDBMS ConceptsSQL - RDBMS Concepts
SQL - RDBMS Concepts
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
 
Sql select
Sql select Sql select
Sql select
 

Viewers also liked

Database system architecture
Database system architectureDatabase system architecture
Database system architectureDk Rukshan
 
Dbms architecture
Dbms architectureDbms architecture
Dbms architecture
Shubham Dwivedi
 
Architecture of-dbms-and-data-independence
Architecture of-dbms-and-data-independenceArchitecture of-dbms-and-data-independence
Architecture of-dbms-and-data-independenceAnuj Modi
 
DBMS Architectures and Features - Lecture 7 - Introduction to Databases (1007...
DBMS Architectures and Features - Lecture 7 - Introduction to Databases (1007...DBMS Architectures and Features - Lecture 7 - Introduction to Databases (1007...
DBMS Architectures and Features - Lecture 7 - Introduction to Databases (1007...
Beat Signer
 
Data independence
Data independenceData independence
Data independence
Aashima Wadhwa
 
Database system concepts
Database system conceptsDatabase system concepts
Database system conceptsKumar
 
2 database system concepts and architecture
2 database system concepts and architecture2 database system concepts and architecture
2 database system concepts and architectureKumar
 
Basic DBMS ppt
Basic DBMS pptBasic DBMS ppt
Basic DBMS ppt
dangwalrajendra888
 
Database management system presentation
Database management system presentationDatabase management system presentation
Database management system presentationsameerraaj
 
Database and Java Database Connectivity
Database and Java Database ConnectivityDatabase and Java Database Connectivity
Database and Java Database Connectivity
Gary Yeh
 
Database System Concepts and Architecture
Database System Concepts and ArchitectureDatabase System Concepts and Architecture
Database System Concepts and Architecture
sontumax
 
Bsc cs ii-dbms- u-ii-database system concepts and architecture
Bsc cs ii-dbms- u-ii-database system concepts and architectureBsc cs ii-dbms- u-ii-database system concepts and architecture
Bsc cs ii-dbms- u-ii-database system concepts and architecture
Rai University
 
Slide 3 data abstraction & 3 schema
Slide 3 data abstraction & 3 schemaSlide 3 data abstraction & 3 schema
Slide 3 data abstraction & 3 schema
Visakh V
 
A N S I S P A R C Architecture
A N S I  S P A R C  ArchitectureA N S I  S P A R C  Architecture
A N S I S P A R C Architecture
Sabeeh Ahmed
 
ADVANCE DATABASE MANAGEMENT SYSTEM CONCEPTS & ARCHITECTURE by vikas jagtap
ADVANCE DATABASE MANAGEMENT SYSTEM CONCEPTS & ARCHITECTURE by vikas jagtapADVANCE DATABASE MANAGEMENT SYSTEM CONCEPTS & ARCHITECTURE by vikas jagtap
ADVANCE DATABASE MANAGEMENT SYSTEM CONCEPTS & ARCHITECTURE by vikas jagtap
Vikas Jagtap
 
physical and logical data independence
physical and logical data independencephysical and logical data independence
physical and logical data independenceapoorva_upadhyay
 

Viewers also liked (20)

Database system architecture
Database system architectureDatabase system architecture
Database system architecture
 
Dbms architecture
Dbms architectureDbms architecture
Dbms architecture
 
Database System Architectures
Database System ArchitecturesDatabase System Architectures
Database System Architectures
 
Architecture of-dbms-and-data-independence
Architecture of-dbms-and-data-independenceArchitecture of-dbms-and-data-independence
Architecture of-dbms-and-data-independence
 
DBMS Architectures and Features - Lecture 7 - Introduction to Databases (1007...
DBMS Architectures and Features - Lecture 7 - Introduction to Databases (1007...DBMS Architectures and Features - Lecture 7 - Introduction to Databases (1007...
DBMS Architectures and Features - Lecture 7 - Introduction to Databases (1007...
 
Data independence
Data independenceData independence
Data independence
 
Database system concepts
Database system conceptsDatabase system concepts
Database system concepts
 
Dbms slides
Dbms slidesDbms slides
Dbms slides
 
2 database system concepts and architecture
2 database system concepts and architecture2 database system concepts and architecture
2 database system concepts and architecture
 
Dbms
DbmsDbms
Dbms
 
Basic DBMS ppt
Basic DBMS pptBasic DBMS ppt
Basic DBMS ppt
 
Database management system presentation
Database management system presentationDatabase management system presentation
Database management system presentation
 
Database and Java Database Connectivity
Database and Java Database ConnectivityDatabase and Java Database Connectivity
Database and Java Database Connectivity
 
Database System Concepts and Architecture
Database System Concepts and ArchitectureDatabase System Concepts and Architecture
Database System Concepts and Architecture
 
Bsc cs ii-dbms- u-ii-database system concepts and architecture
Bsc cs ii-dbms- u-ii-database system concepts and architectureBsc cs ii-dbms- u-ii-database system concepts and architecture
Bsc cs ii-dbms- u-ii-database system concepts and architecture
 
Slide 3 data abstraction & 3 schema
Slide 3 data abstraction & 3 schemaSlide 3 data abstraction & 3 schema
Slide 3 data abstraction & 3 schema
 
A N S I S P A R C Architecture
A N S I  S P A R C  ArchitectureA N S I  S P A R C  Architecture
A N S I S P A R C Architecture
 
ADVANCE DATABASE MANAGEMENT SYSTEM CONCEPTS & ARCHITECTURE by vikas jagtap
ADVANCE DATABASE MANAGEMENT SYSTEM CONCEPTS & ARCHITECTURE by vikas jagtapADVANCE DATABASE MANAGEMENT SYSTEM CONCEPTS & ARCHITECTURE by vikas jagtap
ADVANCE DATABASE MANAGEMENT SYSTEM CONCEPTS & ARCHITECTURE by vikas jagtap
 
physical and logical data independence
physical and logical data independencephysical and logical data independence
physical and logical data independence
 
Types dbms
Types dbmsTypes dbms
Types dbms
 

Similar to Database Architecture and Basic Concepts

SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive
TechandMate
 
Ms sql server ii
Ms sql server  iiMs sql server  ii
Ms sql server iiIblesoft
 
SQL.ppt
SQL.pptSQL.ppt
SQL.ppt
Ranjit273515
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
jainendraKUMAR55
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdf
DraguClaudiu
 
SQLSERVERQUERIES.pptx
SQLSERVERQUERIES.pptxSQLSERVERQUERIES.pptx
SQLSERVERQUERIES.pptx
ssuser6bf2d1
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql newSANTOSH RATH
 
SQL Query
SQL QuerySQL Query
SQL Query
Imam340267
 
chapter 8 SQL.ppt
chapter 8 SQL.pptchapter 8 SQL.ppt
chapter 8 SQL.ppt
YitbarekMurche
 
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQueryPPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
Abhishek590097
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
SakkaravarthiS1
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commandsBelle Wx
 
Lab
LabLab
Data Manipulation Language.pptx
Data Manipulation Language.pptxData Manipulation Language.pptx
Data Manipulation Language.pptx
EllenGracePorras
 
Adbms
AdbmsAdbms
Adbms
jass12345
 
Oraclesql
OraclesqlOraclesql
Oraclesql
Priya Goyal
 

Similar to Database Architecture and Basic Concepts (20)

SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive
 
Ms sql server ii
Ms sql server  iiMs sql server  ii
Ms sql server ii
 
SQL.ppt
SQL.pptSQL.ppt
SQL.ppt
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdf
 
SQLSERVERQUERIES.pptx
SQLSERVERQUERIES.pptxSQLSERVERQUERIES.pptx
SQLSERVERQUERIES.pptx
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
 
SQL Query
SQL QuerySQL Query
SQL Query
 
Sql basics
Sql  basicsSql  basics
Sql basics
 
chapter 8 SQL.ppt
chapter 8 SQL.pptchapter 8 SQL.ppt
chapter 8 SQL.ppt
 
Hira
HiraHira
Hira
 
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQueryPPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
 
Query
QueryQuery
Query
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
 
Lab
LabLab
Lab
 
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
Views, Triggers, Functions, Stored Procedures,  Indexing and JoinsViews, Triggers, Functions, Stored Procedures,  Indexing and Joins
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
 
Data Manipulation Language.pptx
Data Manipulation Language.pptxData Manipulation Language.pptx
Data Manipulation Language.pptx
 
Adbms
AdbmsAdbms
Adbms
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 

Recently uploaded

Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 

Recently uploaded (20)

Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 

Database Architecture and Basic Concepts

  • 1. Database Architecture and Basic Concepts What is Database? Structured Query Language Stored Procedures
  • 2. What is Database?  A database is an object for storing complex, structured information.  What make database unique is the fact that databases are design to retrieve data quickly.  Database samples such as Access and SQL Server called database management systems (DBMS).  To access the data stored in the database and to update the database, you use a special language, Structure Query Language (SQL).
  • 5. Structure Query Language  SQL (Structured Query Language) is a universal language for manipulating tables, and every database management system (DBMS) supports it.  SQL is a nonprocedural language.  SQL statements are categorized into two major categories:  Data Manipulation Language (DML)  Data Definition Language (DDL)
  • 6. Continue…  Executing SQL Statements.  Opening Microsoft SQL Server Management Studio  Using New Query Windows.
  • 7. Continue…  Selection Queries  The simplest form of the SELECT statement is SELECT fields FROM tables where fields and tables are comma-separated lists of the fields you want to retrieve from the database and the tables they belong to.
  • 8.  WHERE Clause To restrict the rows returned by the query, use the WHERE clause of the SELECT statement. The most common form of the SELECT statement is the following: SELECT fields FROM tables WHERE condition The fields and tables arguments are the same as before. Sample: SELECT ProductName, CategoryName FROM Products WHERE CategoryID In (2, 5,6,10)
  • 9.  TOP Keyword  Some queries may retrieve a large number of rows, while you‟re interested in the top few rows only.  The TOP N keyword allows you to select the first N rows and ignore the remaining ones.  DISTINCT Keyword  The DISTINCT keyword eliminates any duplicates from the cursor retrieved by the SELECT statement. SELECT DISTINCT Country FROM Customers
  • 10.  ORDER Keyword  The rows of a query are not in any particular order. To request that the rows be returned in a specific order, use the ORDER BY clause, whose syntax is ORDER BY col1, col2, . . . SELECT CompanyName, ContactName FROM Customers ORDER BY Country, City
  • 11.  SQL Join  Joins specify how you connect multiple tables in a query, and there are four types of joins:  Left outer, or left join  Right outer, or right join  Full outer, or full join  Inner join  Left Joins This join displays all the records in the left table and only those records of the table on the right that match certain user-supplied criteria. This join has the following syntax: FROM (primary table) LEFT JOIN (secondary table) ON (primary table).(field) (comparison) (secondary table).(field) SELECT title, pub_name FROM titles LEFT JOIN publishers ON titles.pub_id = publishers.pub_id
  • 12.  Right Joins This join is similar to the left outer join, except that all rows in the table on the right are displayed and only the matching rows from the left table are displayed. This join has the following syntax: FROM (secondary table) RIGHT JOIN (primary table) ON (secondary table).(field) (comparison) (primary table).(field) “SELECT title, pub_name FROM titles RIGHT JOIN publishers ON titles.pub_id = publishers.pub_id”  Full Joins The full join returns all the rows of the two tables, regardless of whether there are matching rows or not. In effect, it‟s a combination of left and right joins. “SELECT title, pub_name FROM titles FULL JOIN publishers ON titles.pub_id = publishers.pub_id”
  • 13.  Inner Joins This join returns the matching rows of both tables, similar to the WHERE clause, and has the following syntax: FROM (primary table) INNER JOIN (secondary table) ON (primary table).(field) (comparison) (secondary table).(field) “SELECT titles.title, publishers.pub_name FROM titles, publishers WHERE titles.pub_id = publishers.pub_id” Or “SELECT titles.title, publishers.pub_name FROM titles INNER JOIN publishers ON titles.pub_id = publishers.pub_id”
  • 14.  Grouping Rows  Sometimes you need to group the results of a query, so that you can calculate subtotals. SELECT ProductID, SUM(Quantity * UnitPrice *(1 - Discount)) AS [Total Revenues] FROM [Order Details] GROUP BY ProductID ORDER BY ProductID
  • 15.  Action Queries  Execute queries that alter the data in the database‟s tables.  There are three types of actions you can perform against a database: 1. Insertions of new rows (INSERT) 2. Deletions of existing rows (DELETE) 3. Updates (edits) of existing rows (UPDATE)  Deleting Rows The DELETE statement deletes one or more rows from a table, and its syntax is: DELETE table_name WHERE criteria “DELETE Orders WHERE OrderDate < „1/1/1998‟ ”
  • 16.  Inserting New Rows The syntax of the INSERT statement is: INSERT table_name (column_names) VALUES (values) column_names and values are comma-separated lists of columns and their respective values. “INSERT Customers (CustomerID, CompanyName) VALUES („FRYOG‟, „Fruit & Yogurt‟)” Or “INSERT INTO SelectedProducts SELECT * FROM Products WHERE CategoryID = 4”
  • 17.  Editing Existing Rows The UPDATE statement edits a row‟s fields, and its syntax is UPDATE table_name SET field1 = value1, field2 = value2, … WHERE criteria “UPDATE Customers SET Country=‟United Kingdom‟ WHERE Country = „UK‟ “
  • 20. Stored Procedures  Stored procedures are short programs that are executed on the server and perform very specific tasks.  Any action you perform against the database frequently should be coded as a stored procedure, so that you can call it from within any application or from different parts of the same application.  Benefit:  Stored procedures isolate programmers from the database and minimize the risk of impairing the database‟s integrity.  You don‟t risk implementing the same operation in two different ways.  Using stored procedures is that they‟re compiled by SQL Server and they‟re executed faster.  Stored procedures contain traditional programming statements that allow you to validate arguments, use default argument values, and so on.  The language you use to write stored procedure is called T-SQL, and it‟s a superset of SQL.
  • 21. ALTER PROCEDURE dbo.SalesByCategory @CategoryName nvarchar(15), @OrdYear nvarchar(4) = „1998‟ AS IF @OrdYear != „1996‟ AND @OrdYear != „1997‟ AND @OrdYear != „1998‟ BEGIN SELECT @OrdYear = „1998‟ END SELECT ProductName, TotalPurchase = ROUND(SUM(CONVERT(decimal(14,2), OD.Quantity * (1-OD.Discount) * OD.UnitPrice)), 0) FROM [Order Details] OD, Orders O, Products P, Categories C WHERE OD.OrderID = O.OrderID AND OD.ProductID = P.ProductID AND P.CategoryID = C.CategoryID AND C.CategoryName = @CategoryName AND SUBSTRING(CONVERT(nvarchar(22), O.OrderDate, 111), 1, 4) = @OrdYear GROUP BY ProductName ORDER BY ProductName