DATABASE DESIGN AND DEVELOPMENT (IT2140) - LECTURE 02: SQL

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/36

flashcard set

Earn XP

Description and Tags

A comprehensive set of practice flashcards covering SQL fundamentals from Lecture 02, including DDL, DML, constraints, joins, aggregation, and query clauses.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

37 Terms

1
New cards

What was SQL initially called?

SEQUEL (Structured English Query Language).

2
New cards

SQL was developed for which experimental relational database system?

System R.

3
New cards

Which two organizations led to the standard version of SQL in 1986?

ANSI (American National Standards Institute) and ISO (International Standards Organization).

4
New cards

What is SQL-92 commonly called?

SQL2.

5
New cards

Name the main components and facilities of SQL mentioned in the lecture.

Data Definition Language (DDL), Data Manipulation Language (DML), security/authorization, transaction processing, and Embedded SQL.

6
New cards

What does the Data Definition Language (DDL) subset of SQL do?

Supports creation, deletion, and modifications of tables and views (with constraints).

7
New cards

List the constraints that can be defined on a table in DDL.

NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY, DEFAULT, CHECK.

8
New cards

In the CREATE TABLE STUDENT example, which constraint defines the primary key?

studentId INTEGER PRIMARY KEY.

9
New cards

Which constraint ensures a column does not contain null values?

NOT NULL.

10
New cards

What does the UNIQUE constraint do?

Ensures all values in a column are unique (no duplicates).

11
New cards

What is the purpose of the DEFAULT constraint?

Defines a default value for a column when no value is provided.

12
New cards

What is a CHECK constraint used for?

Validates data in a column (e.g., CHECK (gpa <= 4.0)).

13
New cards

Which constraint is used to define a foreign key relationship?

FOREIGN KEY.

14
New cards

In the STUDENT table example, what does the FOREIGN KEY (progId) REFERENCES programs(id) specify, including any actions?

progId references id in programs; ON DELETE SET DEFAULT and ON UPDATE CASCADE define behavior on delete/update.

15
New cards

What is ALTER TABLE used for?

To alter the definition of a table (e.g., add a column or a constraint).

16
New cards

How do you add a new column to a table?

ALTER TABLE student ADD age INT.

17
New cards

How do you add a constraint to a column using ALTER TABLE?

ALTER TABLE student ADD CONSTRAINT chk_age CHECK (age > 18).

18
New cards

How do you remove a column from a table?

ALTER TABLE student DROP COLUMN age.

19
New cards

What is the SQL command to drop a table?

DROP TABLE Employee.

20
New cards

What does the Data Manipulation Language (DML) allow you to do?

Insert, delete, modify, and display rows.

21
New cards

What is the syntax to insert a row into a table?

INSERT INTO student VALUES (1000, 'Amal', '123456789V', 3.2, 'BM').

22
New cards

What is the SQL command to delete a row from a table?

DELETE FROM student WHERE studentId = 1000.

23
New cards

What is the SQL command to update a row's data?

UPDATE student SET gpa = 2.8 WHERE studentId = 1001.

24
New cards

What is the basic form of a SELECT statement?

SELECT FROM WHERE .

25
New cards

What is the LIKE operator used for and what are the wildcards?

Pattern matching; % matches any sequence of characters, _ matches any single character.

26
New cards

What does IS NULL / IS NOT NULL check for?

Whether an attribute value is NULL.

27
New cards

What does the DISTINCT operator do in a SELECT statement?

Removes duplicate values from the result set.

28
New cards

What does the BETWEEN operator do?

Checks whether a value lies within a specified range (inclusive).

29
New cards

What is the ORDER BY clause used for?

Sorting results by one or more columns; defaults to ASC unless DESC is specified.

30
New cards

What is an INNER JOIN?

Joins two tables based on a condition and returns matching rows from both tables.

31
New cards

What does a LEFT OUTER JOIN return?

All rows from the left table and the matching rows from the right; non-matching right rows show NULL.

32
New cards

What does a RIGHT OUTER JOIN return?

All rows from the right table and the matching rows from the left; non-matching left rows show NULL.

33
New cards

What are common aggregate functions in SQL?

SUM, COUNT, AVG, MIN, MAX.

34
New cards

What is the purpose of GROUP BY in SQL?

Groups the data by values of specified columns and produces a single summary row per group.

35
New cards

What is the HAVING clause used for?

Applying conditions to groups produced by GROUP BY (group-level filtering).

36
New cards

What is the overall SQL query structure summarized in the lecture?

SELECT FROM [WHERE ] [GROUP BY ] [HAVING ] [ORDER BY ].

37
New cards

What should you do by next week according to the notes?

Try the self-test questions on the course website and complete the tutorial.