0% found this document useful (0 votes)
30 views34 pages

Unit 2 - Declarative

The document discusses declarative programming paradigms. Declarative programming expresses the logic of a computation without describing its control flow. Common declarative languages include SQL, logic programming and functional programming. The document also provides examples of declarative languages like Prolog, Lisp, SQL and markup languages.

Uploaded by

Sai sathvika
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)
30 views34 pages

Unit 2 - Declarative

The document discusses declarative programming paradigms. Declarative programming expresses the logic of a computation without describing its control flow. Common declarative languages include SQL, logic programming and functional programming. The document also provides examples of declarative languages like Prolog, Lisp, SQL and markup languages.

Uploaded by

Sai sathvika
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
You are on page 1/ 34

DECLARATIVE

PROGRAMMING
PARADIGM
INTRODUCTION
◦Declarative programming is a programming paradigm that expresses the
logic of a computation without describing itscontrol flow.
◦This paradigmoften considers programs as theories of a formal logic,
and computations as deductions in that logic space.
◦Declarative programming is often defined as any style of programming
that is not imperative.
◦Common declarative languages include those of database query
languages (SQL), logic programming, functional programming, etc.
HISTORY

DECLARATIVE

FUNCTIONAL LOGIC
- Lambda calculus - First Order Logic
- Lisp - Prolog
OVERVIEW
◦A programthat describes what computation should be
performed and not how to compute it. Non-imperative,
non-procedural.
◦Any programming languagethat lacksside effects(example: a
function mightmodify a global variable or static variable,
modify one of its arguments, raise an exception,).
◦A languagewith a clear correspondence to mathematical
logic.
OVERVIEW – Logic Paradigm
◦Computing takes place overthe domainof all terms
defined over a “universal” alphabet.
◦Valuesare assigned to variables bymeans of
automatically generated substitutions, called most
general unifiers. These values may contain variables,
called logical variables.
◦Thecontrol is provided bya single mechanism: automatic
backtracking.
Declarative Semantics Vs Imperative Semantics
◦In declarative semantics the meaningof a given proposition
in a logic programming languagecan be concisely determined
from the statement itself.
◦In an imperative language, the semantics of a simple
assignment statement requires examination local declarations,
scoping rules of the language, typesof variables in the
assignment statement, depends on its run-time context.
SQL - StructuredQuery Language
◦SQL is the standardlanguageused to communicate with a
relational database.

◦Itcan be used to retrieve data from a database using a query


but it can also be used to create , destroy as well as modify
theirstructure.
SQL - ELEMENTS
◦The language is subdivided into several language elements,
including:
◦Clauses
◦Expressions
◦Predicates
◦Queries
◦Statements
SQL – DATA TYPES
Some of The Most Important SQL Commands
◦ SELECT - extracts data from a database
◦ UPDATE - updates data in a database
◦ DELETE - deletes data from a database
◦ INSERT INTO - inserts new data into a database
◦ CREATE DATABASE - creates a new database
◦ ALTER DATABASE - modifies a database
◦ CREATE TABLE - creates a new table
◦ ALTER TABLE - modifies a table
◦ DROP TABLE - deletes a table
◦ CREATE INDEX - creates an index (search key)
◦ DROP INDEX - deletes an index
SQL EXAMPLES – INSERT INTO
WHERE CLAUSE

ORDER BY
UPDATE
DELETE
ALTER – ADD COLUMN
◦A
ALTER – DELETE COLUMN

◦In SQLite V3.20.1 it is not possible to rename a column, remove a column,


or add or remove constraints from a table.
MARKUP LANGUAGE
◦ Many markup languages suchas HTML, MXML, XAML are often declarative.

◦ XAML (Extensible Application Markup Language) is a declarative XML-based languagethat is


usedfor initializing structured values and objects. It is used extensively in .NET
Framework 3.0 and .NET Framework 4.0 technologies, particularly WPF (Windows Presentation
Foundation), Silverlight, Windows Store Apps…

◦ In WPF, XAML forms a user interface markup language to define UI elements, data binding,
eventing, and other features. Anythingthat is created or implemented in XAML can be
expressed using a more traditional .NET language suchas C# or Visual Basic .NET.
DEMO
SQL EXAMPLES – INSERT INTO
SQL in PYTHON

You might also like