Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Notas de lectura

GOAT Notes: Databases

Puntuación
-
Vendido
-
Páginas
70
Subido en
07-06-2024
Escrito en
2023/2024

Are you a second-year Computer Science student at the University of Cape Town looking for a comprehensive study aid to excel in your practicals, tests, and exams? Look no further! These meticulously crafted digital lecture notes cover databases.

Mostrar más Leer menos
Institución
Grado

Vista previa del contenido

BEN FROST

GOAT NOTES: DATABASES (CSC2001F)
Structured Query Language (SQL):

Introduction to Databases:

Databases vs Files:

While files are usually application specific databases are suitable for whole organisations.

Databases eliminate the data duplication and inconsistencies that arise when organisations rely on
large amounts of files.

When managing files every new need requires a new program to be developed and tested.

Multiple user file management is not efficient, secure, reliable or concurrent.

Database Management System (DBMS):

A DBMS keeps all the database’s data in one place and allows multiple users concurrent, easy and
safe access to it.

Facilitates CRUD operations:
Create
Retrieve
Update
Delete
Relational Database Example:

Relation -> Table
Tuple -> Row




1

, BEN FROST
SQL Query Guide:

* SEE SQL CHEAT SHEET FOR MORE *
Create:

Insert:
INSERT INTO <TableName>
VALUES (<Col1Value>, <Col2Value>, ... , <ColnValue>);

Insert (Nested): Data Types:
INSERT INTO <TableName> INTEGER, FLOAT,
VALUES (<SelectQuery>); ENUM(v,v,v,v,v), DOUBLE, REAL,
NUMERIC, BIT, VARCHAR, DATE
Table Creation: etc. (see slides)
CREATE TABLE <NewTableName> Null Handling:
NULL -> Allows Null Values
(<Col1Name> <DataType> <NullHandling>,
NOT NULL -> No Null Values
<Col2Name> <DataType> <NullHandling>,
...
<ColnName> <DataType> <NullHandling>,
PRIMARY KEY (<ColiName>, ... ,<ColjName>),
CHECK (<ColiName> IN (<SelectQueryOnPKeyOrigin>))
CHECK (<ColjName> IN (<SelectQueryOnPKeyOrigin>))
);

Retrieve:

Select Specific Columns of Row:
SELECT <Col1Name>, ... ,<ColnName>
FROM <TableName>;

Select All Columns of Row:
SELECT *
FROM <TableName>;

Select Ordered (Ascending):
SELECT <ColiName>
FROM <TableName>
ORDER BY <Col1Name>, ... ,<ColnName>;

Select Ordered (Descending):
SELECT <ColiName>
FROM <TableName>
ORDER BY <Col1Name>, ... ,<ColnName> DESC;

Select By Logical Condition:
SELECT <ColiName>

2

, BEN FROST
FROM <TableName>
WHERE <LogicalCondition>;


Logical Condition Configurations:
Standard Comparison:
WHERE <ColiName> = | <= | >= | < | > <Value>;
Starts With:
WHERE <ColiName> LIKE “<Value>%”;
Ends With: _ -> One Char Wildcard
WHERE <ColiName> LIKE “%<Value>”;
Contains:
WHERE <ColiName> LIKE “%<Value>%”;
&&:
WHERE <Logical1Condition> AND <Logical2Condition>;
||:
WHERE <Logical1Condition> OR <Logical2Condition>;
!:
WHERE NOT <LogicalCondition>;
Between:
WHERE <ColiName> BETWEEN <LowerBound> AND <UpperBound>;
Null/Not Null:
WHERE <ColiName> IS NULL; | WHERE <ColiName> IS NOT NULL;

Select Distinct Row:
SELECT DISTINCT <Col1Name>, ... ,<ColnName>
FROM <TableName>;

Select Top n Ordered Rows:
SELECT TOP <Value> <Col1Name>, ... ,<ColnName>
FROM <TableName>
ORDER BY <Col1Name>, ... ,<ColnName>;

Operations:
Mathematical:
Brackets:
()
Exponentiate:
POWER(<Value>, <Exponent>)
Division:
/
Multiplication:
*
Addition:
+
Subtraction:

3

, BEN FROST
-
Set Theory:
Union:
<SelectedSet> UNION <SelectedSet> Set functions all retain
Intersect: duplicates. Selected
<SelectedSet> INTERSECT <SelectedSet> relations’ structures must
match.
Except:
<SelectedSet> EXCEPT <SelectedSet>
Number Functions:

Sum:
SUM(<ColiName>)
Round:
ROUND(<Value>, <numberOfDecimalPlaces>)
Count:
COUNT(<ColiName>)
Minimum:
MIN(<ColiName>)
COUNT(*) includes NULL Values
Maximum:
MAX(<ColiName>) Everything else ignores them.
Average:
AVG(<ColiName>)
Floor:
INT(<Value>)
Generate Random Number:
RND(<ColiNameAsSeed>) * (<Range>) + <lowerLim>
Modular Division (%):
<Value1> MOD <Value2>
Integer Division:
<Value1> \ <Value2>

String Functions:

Substring From Left:
LEFT(<String>,<NumberOfChars>)
Substring From Right:
RIGHT(<String>,<NumberOfChars>)
Substring From Middle (to Right):
MID(<String>, <StartPosition> ,<NumberOfChars>)

COALESCE Function: COALESCE takes the first non-NULL
COALESCE(<Col1Name>, ... ,<ColnName>) value of the specified columns. (in order)

Deriving Functions As New Output Columns:
SELECT <FunctionOnTable> AS <NewColumnName>
FROM <TableName>;

4

Escuela, estudio y materia

Institución
Grado

Información del documento

Subido en
7 de junio de 2024
Número de páginas
70
Escrito en
2023/2024
Tipo
NOTAS DE LECTURA
Profesor(es)
Sonia berman
Contiene
Todas las clases

Temas

$3.01
Accede al documento completo:

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Conoce al vendedor
Seller avatar
benfro764

Documento también disponible en un lote

Conoce al vendedor

Seller avatar
benfro764 University of Cape Town
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
5
Miembro desde
1 año
Número de seguidores
0
Documentos
3
Última venta
2 semanas hace

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Documentos populares

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