Database Design Test 3 - John Stone

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

1/33

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

34 Terms

1
New cards

Alternate Join Type

Left and Right Join

2
New cards

Create Table Statements

Used for creating relations

3
New cards

Create Table Statement example

CREATE TABLE (

three-part column definition,

three-part column definition,

...

optional table constraint

...

);

4
New cards

3 parts of a column description

1. Column Name

2. Data Type

3. Optional Constraint

5
New cards

Table Constraints

NOT NULL/NULL

UNIQUE

DEFAULT

CHECK

PRIMARY KEY

FOREIGN KEY

6
New cards

Most common SQL server data types

Int, Char(n), Varchar(n), Numeric(digits before decimal, digits after decimal), Money, Date

7
New cards

Implementation of 1:1 table relationships

Parent required

specify foreign key constraint, specify foreign key unique, specify foreign key NOT NULL

8
New cards

Implementation of 1:N table relationship

Parent required

specify foreign key constraint, set foreign key NOT NULL

9
New cards

Alter Statement (and caveats)

Add, remove, change columns or constraints in an existing table

(there is no undo button)

10
New cards

Alter table statement example

ALTER TABLE CUSTOMER

ADD MyColumn Char(5) NULL;

11
New cards

Drop statements (and cavets)

Used to drop an existing column or constraint in an existing table

(must drop child before parent)

12
New cards

Drop statement example

ALTER TABLE CUSTOMER

DROP COLUMN MyColumn;

13
New cards

Insert statements (and caveats)

Insert rows of data into a table that exists

14
New cards

Insert statement example

INSERT INTO ARTIST

(LastName, FirstName, Nationality, DateOfBirth, DateDeceased)

VALUES ('Miro', 'Joan', 'Spanish', 1893, 1983);

15
New cards

Bulk insert statement example

INSERT INTO ARTIST

(LastName, FirstName, Nationality, DateOfBirth, DateDeceased)

SELECT LastName, FirstName, Nationality,

DateOfBirth, DateDeceased

FROM IMPORTED_ARTIST;

16
New cards

Update statements (and caveats)

used to change values of existing rows

(need a where clause otherwise every row gets changed)

17
New cards

Update statement example

UPDATE CUSTOMER

SET City = 'New York City', State = 'NY'

WHERE CustomerID = 1000;

18
New cards

Delete Statement (and caveats)

Deletes rows from existing tables

(need a where clause otherwise you delete the whole table, DELETE does not reset surrogate key values)

19
New cards

LEFT Join

EVEN IF, REGARDLESS WHETHER OR NOT

Select *

FROM suppliers LEFT JOIN Products

ON supplier.supplierid = products.supplierid ;

20
New cards

RIGHT JOIN

EVEN IF, REGARDLESS WHETHER OR NOT

select *

FROM products RIGHT JOIN suppliers

ON product.supplierid = suppliers.supplierid

21
New cards

SQL views

a virtual table constructed from other Table's and views

(good for presenting information from the database)

22
New cards

Triggers

A stored program executed by the DBMS whenever a specified event occurs

23
New cards

3 types of triggers

BEFORE

INSTEAD OF

AFTER

24
New cards

how many triggers does oracle have

9 (all 3 types and they all have update, insert, delete)

25
New cards

how many triggers does SQL server have

6 (INSTEAD OF, AFTER both have update, insert, delete)

26
New cards

how many triggers does MySQL have

6 (BEFORE, AFTER both have insert, update, delete)

27
New cards

stored procedures

a program stored within a database and is compiled when used

28
New cards

correlated subquery

looks like a normal subquery

processing is nested and it executes simultaneously

used to check functional dependencies

29
New cards

EXISTS

comparison operator in a subquery that returns a non-empty set of values if all row in the subquery that meets a specified condition

30
New cards

NOT EXISTS

comparison operator in a subquery that returns an EMPTY set of values if all row in the subquery fail to meet a specified condition

31
New cards

Double NOT EXISTS

double nested

checks for more comparisons in more tables

(used often to check SQL knowledge)

32
New cards

full backup

backup of all data and structure that exists in that moment

33
New cards

differential backups

backup of all changes since the last full backup

34
New cards

3 principles of Database Redesign

1. Measure twice cut once

2. Test new changes before changing the actual database

3. Create a complete backup of the operational database before making changes