Week 7 Flashcards

1
Q

What is a view?

A

a view is a virtual table!!! basically making it virtually

CREATE VIEW view_name AS
SELECT column1, column2, …
FROM table_name
WHERE condition

you can do all the things!!! inner joins and all the others week 5 studd

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

What does isnull(__,0) function do?

A

replaces all null values with 0

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

wHAT IS a dynamic view

A

virtual table created dynamically base don user request

no data actuall stroed

instead data from base table is aavialbel for user

based on sql select statmeemtns on basee tabls or other views

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

Materialized view

A

Copy or replication of data

DATA IS ACTUALLY STORED

Must be regreshed periodically to match correpsonding base table

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

pros of dynamic views

A

simplify query commands

assist with data security

enhance programming productivity

contain most current base table data

use little stroage space

provide custom view for user

establsih physical data independance

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

cons of dynamic views

A

use processing time each time view is references

may/may not be directly updatebale

as with al sql constructs, you should use views with discretion

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

what is a routine

A

program modules that execute on demand

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

3 compeonents of a tourine

A

function: routines that return values and take input paramaeters

stored procedure: routines that do not return values and can take input or output parameters

triggers: routines that executive in response to a db event (insert, update, deletE)

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

what is a stored procedure

A

if you are repeating an excel query constantlty, you can save it as a stored proceudre and then call it or execute it

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

example of stored proceudre

A

CREATE PROCEDURE (name)
@parameter1 datatyp
@parameter2 datatype
AS —-
BEGIN
SQL statmeents
END

LIKE,,,,,,,,,,,,,,,,,,,,,,,

CREATE PROCEDURE SelectProduct AS
begin
SELECT * FROM Product_T;
end

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

how to execute a stroed proceduree

A

EXEC procedure naem

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

What is an index?

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

what is a clustered index

A

sort and store the data riws in the table or view based in their key values

CREATE INDEX index1 ON table1 (column1)

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

Nonclustered index

A

having a structure separate from the data rows

containing key values and each key value entry has a pointer to the data row that contains the key value

CREATE CLUSTERED INDEX index1 ON table1 (column1)

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

How do you access data dictionary in sql server

A

metadata in sql server cannot be queried directly, it is exposed in

CATALOG VIEWS
INFO SCHEMA VIEWS

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

where are the catalaog views?

A

in the sys schema

SELECT * FROM sys.objects
WHERE type_desc=’USER_TABLE

17
Q

Info schema view

A
  • very similar to catalog views
  • Provide a standard method for accessing metadata
    across different relational databases

-Provided more limited information than Catalog views

18
Q

example for info schema views

A

SELECT * FROM
INFORMATION_SCHEMA.TABLES

19
Q

tips for dev queries

A

Be familiar with the data model (entities and relationships)

Understand the desired results

Know the attributes desired in results

Identify the entities that contain desired attributes

Review ERD

Construct a WHERE equality for each link

Fine tune with GROUP BY and HAVING clauses if needed

Consider the effect on unusual data

20
Q

the less subqueries the better

A

!!

21
Q

If data is to be used many times, make a separate query and
store it as a view

A
22
Q
A