Standard Computer Language - Database Design - Lecture Slides, Slides of Database Management Systems (DBMS)

This lecture slide is very easy to understand and very helpful to built a concept about the foundation of computers and Database Design.The key points in these slides are:Standard Computer Language, Access Database, Retrieve Data, Execute Queries, Insert New Records, Delete Records from Database, Definitions and Data Types, Creating Tables, Dropping Table, Order Elements, Aggregates

Typology: Slides

2012/2013

Uploaded on 04/27/2013

asavari
asavari 🇮🇳

4.7

(15)

93 documents

1 / 18

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
SQL
SQL stands for Structured Query Language
SQL allows you to access a database
SQL is an ANSI standard computer language
SQL can execute queries against a database
SQL can retrieve data from a database
SQL can insert new records in a database
SQL can delete records from a database
SQL can update records in a database
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Partial preview of the text

Download Standard Computer Language - Database Design - Lecture Slides and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

SQL

SQL stands for S tructured Q uery L anguage SQL allows you to access a database SQL is an ANSI standard computer language SQL can execute queries against a database SQL can retrieve data from a database SQL can insert new records in a database SQL can delete records from a database SQL can update records in a database

History

  • Was designed and implemented by IBM Research (1986)
  • A joint with American National standards Institute (ANSI) and International Standards Organization (ISO) led to the standard version of SQL-
  • A revised and expanded in 1992 called SQL-92.
  • Most recent is now SQL-

Common Data Types

  • char (size) – Fixed length character string. Size is specified in parenthesis. Max 255 bytes.
  • varchar (size) – Variable-length character string. Max size is specified in parenthesis.
  • number (size) – Number value with a max number of column digits specified in parenthesis.
  • date – Date value
  • number (size, d) – Number value with a max number of digits of “size” total, with a max number of “d” digits to the right of the decimal.

Creating Tables

• Create Table – used to specify a new relation

by giving it a name, and attributes with initial

constraints.

  • Example: CREATE TABLE company.employee …
    • Company is the schema name
    • Employee is the relation name

Other Functions

• Select – allows you to select a certain and

retrieve data specified.

  • Example: Select “column1” From “TableName” Where “condition”;

• Select column 1 from the TableName with the

following condition.

Insertion

Insert into “tablename” (first_column, … last_column) values (first_value,…last_value);

Insert into employee (first, last, age, address, city, state) values (‘James’, ‘Tran’, 23, ‘1111 1 st^ street’, ‘San Jose’, ‘California’);

  • Inserts into specified table name
  • Specify all columns inserting to separated by a comma.
  • Values inserted are specified afterwards
  • Strings enclosed in single quotes, numbers are not.

Deleting

delete from “tablename”

where “columnname”

OPERATOR “value” [and | or “column” OPERATOR “value”];

[ ] = optional

  • Delete a certain table, column, row, etc.
  • Operator meaning >,<,=, etc…

Drop

• Dropping a table removes all rows and

definitions.

• Example: Drop table “TableName”

Evaluation of GroupBy with Having

Aggregates

• More functions that allow you to operate on

sets.

  • COUNT, SUM, AVG, MAX, MIN
    • Produces numbers, not tables.
    • Not part of relational algebra
  • Example: Select MAX (Age)

From Employee E

Grouping Cont

• Example:

  • SELECT Dno, COUNT(*), AVG (Salary)

FROM EMPLOYEE

GROUP BY Dno;

  • The EMPLOYEE tuples are partitioned into groups,

each group having the same value for the

grouping attribute Dno.

  • Then the COUNT and AVG functions are applied to

each group.

A

A

A

A

A

A

A

A

A

A

A

A

A

A

A

A

A

A

A

Two tables

a) b)

R(A) UNION ALL S(A)

c)

d)

A

A

A

A

A

A

R(A) EXCEPT ALL S(A)

R(A) INTERSECT S(A)

SQL Multiset

Operations

R S T

T

T