Lecture 6: SQL - DDL, DML Flashcards

1
Q

What is SQL?

A

formal and de facto standard language for relational databases

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

DDL?

A

is the language to create, transform and control databases

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

DML

A

is the language to access and transform data in the databases

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

DCL

A

sets up privileges and roles. (data control language)

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

Reserved words are a fixed part of SQL and must be spelt exactly as required and cannot be split across lines.

List the reserved words in SQL.

A
CREATE
TABLE
SELECT
INDEX
VIEW
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

User-defined words are made up by users and represents names of various database objects such as relations, customers, views

A

CUSTOMER
STUDENT
UNITS
Customer_Id

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

What are Literals?

A

literals are constants used in SQL statements

e.g. ‘London’, or 650.00

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

List database objects

A
  1. tables
  2. indexes
  3. views
  4. constraints
  5. users
  6. etc
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

list and explain three DDL commands

A
  1. create
  2. alter
  3. drop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

List a typical process to create tables

A
  1. identify the table name
  2. identify the columns and their data types
  3. identify the constraints (nulls, PK, FK)
  4. create tables one by one paying attentions to referential constraints (FK)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

List 5 integrity features of SQL

A
  1. required data
  2. domain constraints
  3. entity integrity (PK rule)
  4. Referential Integrity (FK Rule)
  5. General constraints
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Why is NOT NULL used?

A

if certain table columns are important and always require a value we can declare them as not null.

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

List three constraints

A
  1. check constraint
  2. unique constraint
  3. default constraint
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what is check constraint?

A

used to limit the value range that can be placed in a column. applies to only single column

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

what is a unique constraint?

A

single column, or combination of columns that uniquely defines a row

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

what is default constraint?

A

used to insert a default value into a column

17
Q

What is database object index

A

an index is a structure that is created for fast data retrievals in a query. By default an index will always be created on PK columns

18
Q

What is database object VIEW

A

a virtual table that does not necessarily exist, in the database but is produced upon request, at time of request (aka named query)

e..g create a view so manager at branch B003 can only see details for staff who work in his or her office

19
Q

List three DML commands

A
  1. insert
  2. update
  3. delete