DBMS Restart Flashcards

1
Q

Which way do joins nest

A

left to right

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

Name a data generating function and explain

A

generate_series(), returns a number of rows aka table functions. Can use FROM on this too

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

WITH ORDINALITY

A

meaning that it will be output as a sequence numbering its values.

ex. SELECT * FROM generate_series() with ordinality.

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

Type Casting in Postgres

A

CAST() or use :: operator

ex. CAST(sal as int)

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

Bit Strings

A

Sequences of 0s and 1s. Bit String Data Types in Postgres are:
- bit(n)
- bit varying(n)

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

bit(n)

A

With string length n being fixed at definition

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

bit_varying(n)

A

String length n is the maximum value supported

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

Bit String Operators supported

A

Concat, Bitwise And, Bitwise Or, ~, #, Bitwise shifts

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

CREATE SEQUENCE

A

creates a sequence in columns in order

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

ENUMerated types

A

Define our own types ex. ENUM(‘red’,’blue’,’green’)

Case sensitive + Order is important

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

BLOB

A

Binary Large Object, Basic binary Datatype
ByteA supports binary strings in bits.

This can be a file like a WAV, PNG, EXE etc.

Basically just a file constructed of binary

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

TOAST

A

The Oversized attribute storage techniques supported by pgsql automatically stores values bigger than a single DB page into a secondary storage region. Limits size of any column to 1gb.

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

What risk comes with reading direct from server process

A

Security risks as scripts assume user is a superuser.

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

Array[] Type Constructor

A

Popular in GUI elements, computations and visualizations. Support SQL must define, update, manage and query tables with arrays.

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

How can you map arrays to tuples

A

using the ‘unnest(ARRAY[])’ command.

You can also map tuples to arrays.

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

RANGE Type Constructor

A

Datatypes representing a spread of values by listing the two endpoints and their bounds (inclusive or exclusive)

Can be int, numeric, date, timestamp etc.

[] is used for inclusive
() used for exclusive

17
Q

What are RANGEs used for

A

Schedules for job arrivals, run predicates to determine intersection, intersecting data streams, coalescing of data.

18
Q

Range encoding

A

SELECT ‘[2,8]’ :: int 4 range;

19
Q

Create Range

A

SELECT numrange (1,12);

20
Q

Multirange encoding

A

SELECT ‘{[18,20),[25,65]}’ :: int4multirange;

21
Q

Range predicates

A

Contained, Contains, Follow/Precede

22
Q

Range Predicate: Overlap

A

Overlap of ranges is true when every range shares a common interval together. Overlap ex. dates may occur in a number of ways.

23
Q

Range Operation: Strictly Before

A

Write a query to check if range precedes another (without overlap)

24
Q

Reading and writing data in JSON

A

JSON is a data-interchanged format, from DBMS to another DBMS or client process. It is Language independent. Data building syntax easy to read and apply.

25
Q

What is JSON

A

Semi-structed datatype - any 2 docs can have similar but not necessarily must have identical structures.

Built on objects which are a composition of key and value pairs. Value can be any instances of generics such as number, string, bool, array, object or null.

26
Q

Generate JSON from tables

A

SELECT row_to_json(r) FROM (SELECT …) to ‘file.json’;

27
Q

JSON function

A

-> output value
-» outputs datatype
#> output value in key
@> output true/false (query)
?’x’ output T/F if exists
|| concat
-‘x’ output row without ‘x’