Week 7 - SQL Part 1 Flashcards

1
Q

What are the two categories that SQL functions fit into?

A
  • Data definition language (DDL)
    Includes SQL commands to create database objects such as tables, indexes, and views
  • Data manipulation language (DML)
    Includes SQL commands to insert, update, delete and retrieve data within the database
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the two main tasks to be completed when creating a new database?

A

The two main tasks are:

  1. Create database structure
  • RDBMS creates the physical files that will hold the database
  • differs from on RDBMS to another
  • Usually includes authentication process
  1. Create tables that will hold the end-user data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is authentication?

A

Authentication is the process through which the DBMS verifies that only registered users access the database created. Users should log on to the RDBMS using a user ID and a password created by the database administrator.

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

What is a schema?

A

A schema is Group of database objects such as tables and indexes that are related to each other

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

What are some SQL data types?

A
  • Numeric: number, integer, smallint, decimal
  • Character: char, varchar
  • Date
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the different types of SQL constraints?

A
  • NOT NULL
    Ensures that a column does not accept nulls
  • UNIQUE
    Ensures that all values in a column are unique
  • DEFAULT
    Assigns a value to an attribute when a new row is added to a table
  • CHECK
    Validates data when an attribute value is entered
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the different data manipulation commands in SQL?

A

The data manipulation commands in SQL are:

  • INSERT: Adding table rows
  • COMMIT: Saving table changes
  • SELECT: Listing table rows
  • UPDATE: Updating table rows
  • ROLLBACK: Restoring table contents to state prior to changes
  • DELETE: Deleting table rows
  • INSERT + SELECT - Inserting table rows with a select subquery
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you add a new table row into a table using SQL commands?

A

This is the structure of a command that inserts a new table:

INSERT INTO tablename VALUES (v1, V2,…);

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

What is the syntax for updating table rows?

A

Syntax for updating table rows:

UPDATE tablename
SET columnname = expression [, columnname = expression]
[WHERE conditionlist];

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

What is the syntax for deleting table rows?

A

Syntax for deleting table rows:

DELETE FROM tablename
[WHERE conditionlist]

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