Midterms - syntax. joins, checks Flashcards

1
Q

Syntax

Adding Pk constraint to an existing table using ALTER

A
ALTER TABLE Employee
ADD CONSTRAINT empPk PRIMARY KEY (empId);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Syntax

Composite Primary Key

A
ALTER TABLE Employee
ADD CONSTRAINT empSkillPk
PRIMARY KEY (empId, SkillId);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Syntax

Adding Fk constraint to existing table using ALTER

A
ALTER TABLE Employee
ADD CONSTRAINT empFk FOREIGN KEY (deptId) REFERENCES Department (deptId);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Syntax

Insert

A
INSERT INTO Employee (empId, salaryCode, lastName)
VALUES (62, 11, 'Halrpert');
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Syntax

Update

A
UPDATE Employee
SET phone = '0928 - 960 - 1234'
WHERE empId = 29;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Syntax

Delete

A
DELETE FROM Employee
WHERE empId = 29;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Syntax

Select

A
SELECT empName
FROM Employee
WHERE empId = 33;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Identification

A query pulls information from one or more relations and temporarily creates a new relation

A

Result set

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

Identification

Dependent on the outer query. References columns or relies on a value from the outer query. Is executed repeatedly, once for each row in the outer query.

A

Correlated

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

Identification

Independent of the outer query. Does not reference any value or columns from the outer query. Executed once and the result is used by the outer query.

A

Non-correlated

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

Identification

Another way of combining data from multiple tables

A

Joins

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

Syntax

Inner Join

A
SELECT empName, deptName
FROM Employee e INNER JOIN Department d ON e.deptId = d.deptId;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Syntax

Left Outer Join

A
SELECT empName, deptName
FROM Employee e LEFT OUTER JOIN Department d ON e.deptId = d.deptId;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Syntax

Right Outer Join

A
SELECT empName, deptName
FROM Employee e RIGHT OUTER JOIN Department d ON e.deptId = d.deptId;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Syntax

Full Outer Join

A
SELECT empName, deptName
FROM Employee e
FULL OUTER JOIN Department d ON e.deptId = d.deptId;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Syntax

Union

A
SELECT e.empName, d.deptName FROM employee e LEFT OUTER JOIN department d ON e.deptId = d.deptId 
UNION 
SELECT e.empName, d.deptName FROM employee e RIGHT OUTER JOIN department d ON e.deptId = d.deptId;
17
Q

Syntax

Union All

A
SELECT e.empName, d.deptName 
FROM employee e LEFT OUTER JOIN department d ON e.deptId = d.deptId 
UNION ALL
SELECT e.empName, d.deptName 
FROM employee e RIGHT OUTER JOIN department d ON e.deptId = d.deptId;
18
Q

Syntax

Alter and Drop

A
ALTER TABLE Employee DROP CONSTRAINT empFk;
19
Q

Syntax

Deleting a Database

A

DROP TABLE Employee;

20
Q

Syntax

Check Constraint

A

ALTER TABLE Employee
ADD CONSTRAINT length
CHECK (LENGHT(deptId) >=3);

21
Q

Identification

Retrieves records that have matching values in both tables based on a specified condition, only the rows with matches in both tables are included in the result set

A

Inner Join

22
Q

Identification

Returns all records from the left table and any matching records from the right table. If there’s no match, NULL values are returned for the right table’s columns.

A

Left Outer Join

23
Q

Identification

Returns all records from the right table along with any matching records from the left table. If there’s no match, NULL values are returned for the left table’s columns.

A

Right Outer Join

24
Q

Identification

combines the results of two or more SELECT queries into a single result set, removing duplicate rows

A

Union

25
Q

Identification

combines the results of two or more SELECT queries into a single result set, including all duplicate rows

A

Union All

26
Q

Identification

Returns all records from both tables, combining rows with matching pairs. If no match exists, the missing values in both tables are filled with NULL

A

Full Outer Join

27
Q

Identification

is used to ensure that values in a column meet a specific condition before they are accepted into the database

A

Check Constraint

28
Q

Define

Result set

A

A query pulls information from one or more relations and temporarily creates a new relation

29
Q

Define

Correlated

A

Dependent on the outer query. References columns or relies on a value from the outer query. Is executed repeatedly, once for each row in the outer query.

30
Q

Define

Non-correlated

A

Independent of the outer query. Does not reference any value or columns from the outer query. Executed once and the result is used by the outer query

31
Q

Define

Joins

A

Another way of combining data from multiple tables

32
Q

Define

Inner Join

A

Retrieves records that have matching values in both tables based on a specified condition, only the rows with matches in both tables are included in the result set

33
Q

Define

Left Outer Join

A

Returns all records from the left table and any matching records from the right table. If there’s no match, NULL values are returned for the right table’s columns.

34
Q

Define

Right Outer Join

A

Returns all records from the right table along with any matching records from the left table. If there’s no match, NULL values are returned for the left table’s columns.

35
Q

Define

Union

A

combines the results of two or more SELECT queries into a single result set, removing duplicate rows

36
Q

Define

Union All

A

combines the results of two or more SELECT queries into a single result set, including all duplicate rows

37
Q

Define

Full Outer Join

A

Returns all records from both tables, combining rows with matching pairs. If no match exists, the missing values in both tables are filled with NULL

38
Q

Define

Check Constraint

A

is used to ensure that values in a column meet a specific condition before they are accepted into the database