Lecture 6 Flashcards

1
Q

SQL vs. NoSQL

A

SQL is tables

NoSQL no tables (other forms, like graph)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

SQL is a transform-oriented language with 4 components

A

Data Definition Language (DDL) - defining database structure

Data Manipulation language (DML) - data retrieval, updating, deletion, etc.

Data Control language (DCL) - access control

Transaction Control Language - managing transactions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

some important SQL commands

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

SQL: literal value

A

constants; a fixed data value

  • character* literal: ‘JACK’, ‘BLUE ISLAND’, and ‘101’ (single quotes)
  • numeric* literal: 5001 (no quotes)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

SQL: drop means…

A

delete

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

CREATE TABLE: column paramters & datatype parameters

A

column parameters - specify the names of the columns of the table

datatype parameter - specifies the type of data the column can hold (e.g. varchar, integer, date, etc.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

creating a copy of a table in SQL

A

using CREATE TABLE

  • The new table gets the same column definitions, where all columns or specific columns can be selected
  • If you create a new table using an existing table, the new table will be filled with the existing values from the old table
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

TRUNCATE TABLE

A

deletes the content of the table, but not the table itself (defintions stay)

TRUNCATE TABLE table_name;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

PRIMARY KEY and null values

A

Primary keys must contain UNIQUE values, and cannot contain NULL values; hence add the statement NOT NULL PRIMARY KEY

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

test for a NULL value in SQL

A

The IS NOT NULL condition

It returns TRUE if a non-NULL value is found, otherwise it returns FALSE

It can be used in a SELECT, INSERT, UPDATE, or DELETE statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

FOREIGN KEY

A

used to link two tables together

A FOREIGN KEY is a field (or collection of fields) in one table (child table) that refers to the PRIMARY KEY in another table (parent table)

Use REFERENCES to link the foreign key to another table

FOREIGN KEY (personID) REFERENCES Persons(personID)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

where and what is returned from SELECT

A

The data returned is stored in a result table, called the result-set

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

SQL Query parameters

A

SELECT what elements, i.e. which fields to shown

FROM what datasets, i.e. which tables to search

WHERE condition, i.e. which values match (filter)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly