100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Notas de lectura

Brunel - Computer Science - CS1703 Data and Information Lecture Notes (Exam Revision)

Puntuación
-
Vendido
2
Páginas
33
Subido en
06-01-2024
Escrito en
2018/2019

These are the lecture notes I created which I used to revise for the CS1703 Data and Information for Term 2 only for the exam at Brunel University in which I received a First Class in.

Institución
Grado











Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Institución
Estudio
Desconocido
Grado

Información del documento

Subido en
6 de enero de 2024
Número de páginas
33
Escrito en
2018/2019
Tipo
Notas de lectura
Profesor(es)
Dr alan serrano
Contiene
Term 2

Temas

Vista previa del contenido

Module: CS1703
Lecture Topic: SQL (Part 1)
Week: 17
Structured Query Language (SQL)
-Main language for relational DBMs

Main characteristics:
-Relatively easy to learn
-Declarative, you specify what info you require rather than how to get it
(vs imperative/procedural languages like Java/Python.)
-Essentially free-format
-Consists of standard English words like SELECT, INSERT, and UPDATE
-Can be used by range of users.


Objectives of SQL:
Ideally database languages should let the user:
-create database and table structures
-perform basic tasks like adding (insert), amending (update), and removal (delete)


Must perform these tasks with minimal user effort
Must be portable-must conform to recognised standard (i.e. International standards-ISO)
SQL has two main components:
-DDL (Data definition Language): for defining DB structure and controlling access to data
-DML (Data Manipulation Language): for retrieving and updating data




Writing SQL Commands:
-SQL statement consists of reserved words and user-defined words
-Reserved words are a fixed part of SQL and must be spelled exactly as required and cannot
be split across lines (e.g SELECT, INSERT)
-User-defined words are made up by user and represent names of various database objects
such as tables, columns, views.

,Literals:
-Literals are constants used in SQL statements
-All non-numeric literals must be enclosed in single quotes (eg. ‘New York’)
-Numeric literals are not enclosed in quotes (eg. 650.00)
Example:

INSERT INTO BOOK (bTitle, bPRice)
VALUES(‘Hocus Pocus’, 5.99);


Example of a DB:
Underlines column names are primary keys, convention for representing a relational DB is
to give each table name followed by their column names in brackets

Table (Relation) Columns (Fields, Attributes)

DistributionCenter (dCenterNo, dStreet, dCity,
dState, dZipCode, mgrStaffNo)

Staff (staffNo, name, position, salary,
eMail, dCenterNo)

DVD (catalogNo, title, genre, rating)

Actor (actorNo, actorName)

DVDActor (actorNo, catalogNo, character)

:




SELECT: specifies which columns are to appear in output
FROM: specifies table(s) to be used
WHERE: filters rows subject to some conditions
GROUP BY: forms groups of rows with same column value
HAVING: filters groups subject to some condition.
ORDER BY: specifies the order of the output.

-Order of the clauses cannot be changed.
-Only SELECT & FROM are mandatory.

,“List the full details of all DVDS helds”


SELECT catalogNo, title, genre, rating
FROM DVD;


Or
SELECT *
FROM DVD;


Sometimes rows will have a null value.
“List rentals that have no return date specified”


SELECT staffNo, name, position, salary
FROM Staff
WHERE supervisorStaffNo is NULL;


Distinct keyword
-SELECT does not eliminate duplicate values by default
-Replace SELECT with SELECT DISTINCT
Calculated fields
-allows you to transform existing fields according to some arithmetic operation


SELECT staffNo, name, position, salary /12
FROM Staff;
Calculated fields: AS clause
-to give the column a meaningful name, we use the AS clause
SELECT staffNo, name, position, salary /12 AS monthlySalary
FROM Staff;

, Where clause
-Follows the FROM clause
-Only retrieve rows that satisfy some condition
-Five basic search conditions include:
 Comparison (compares the value of one expression to the value of another)
 range (test whether value falls within a specified range)
 set membership (test whether the value of an expression equals one of a set of
values)
 pattern match: test whether a string matches a specified pattern
 Null: test whether a column has a unknown value




Common operators


= equals
<> is not equal to
> is greater than
< is less than
<= is less than or equal to
>= is greater than or equal to
Logical operators and brackets can be used to express more complex conditions
AND – both conditions must be satisfied
OR – one or both conditions must be satisfied
NOT – condition is false
Comparison search
“List all staff with a salary greater than $40,000”
SELECT staffNo, name, position, salary
FROM Staff
WHERE salary>40000




Range search condition

Conoce al vendedor

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
cslbrunel Brunel University
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
63
Miembro desde
3 año
Número de seguidores
34
Documentos
29
Última venta
4 meses hace
Brunel Computer Science (1st Class Honours)

I achieved a First Class Honours degree in Computer Science from Brunel University - I will be uploading some of my work. Please do not purchase any documents looking for the solution to your assignments or deliverables. No refunds / exchanges.

5.0

2 reseñas

5
2
4
0
3
0
2
0
1
0

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes