PostgreSQL Flashcards

1
Q

What is PostgreSQL and what are some alternative relational databases?

A

PostgreSQL is a powerful, free, open source Relational Database Management System (RDBMS).

Other popular relational databases include MySQL (also free), SQL Server by Microsoft, and Oracle by Oracle Corporation.

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

What are some advantages of learning a relational database?

A

Relational databases are arguably the most widely used kind of database. Many times when developers create a full stack developer, they are using a relational database.

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

What is one way to see if PostgreSQL is running?

A

sudo service postgresql status

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

What is a database schema?

A

A collection of tables is called a schema. A schema defines how the data in a relational database should be organized.

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

What is a table?

A

A table is data that is in a list of rows where rows each have the same set of attributes.

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

What is a row

A

A single instance of record in that table

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

What is SQL and how is it different from languages like JavaScript?

A

SQL is a declarative programming language. In declarative languages, programmers describe the results they want and the programming environment comes up with its own plan for getting those results.

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

How do you retrieve specific columns from a database table?

A

Use the select keyword followed by the name of the column.

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

How do you filter rows based on some specific criteria?

A

Use the select and where clause; expression that evaulates to true or false

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

What are the benefits of formatting your SQL?

A

For readability

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

What are four comparison operators that can be used in a where clause?

A

> < = !=

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

How do you limit the number of rows returned in a result set?

A

Keyword limit followed by a number for the number of rows

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

How do you retrieve all columns from a database table?

A

Select *

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

How do you control the sort order of a result set?

A

Keyword order by column name ___ (default is ascending) and if want descending put desc

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

How do you add a row to a SQL table?

A

insert into “name of table to insert to” (“column names separated by commas”)
values (’text values wrapped in single quotes’, number values with literal numbers);

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

What is a tuple?

A

In SQL, a list of values is referred to as a tuple.

17
Q

How do you add multiple rows to a SQL table at once?

A

Data rows can be batch inserted into a database table by specifying more than one tuple of values, separated by commas

18
Q

How to you get back the row being inserted into a table without a separate select statement?

A

Keyword returning *;

19
Q

How do you update rows in a database table?

A

update “table name”

set “attribute column name” = ‘value’ and no single quotes if it’s a number value

20
Q

Why is it important to include a where clause in your update statements?

A

You don’t want to update every row to have the same value (unless that is what you intend to do)

21
Q

How do you delete rows from a database table?

A

Keyword delete from and table name and followed a where clause!!!! If not, the entire table will be deleted

22
Q

How do you accidentally delete all rows from a table?

A

By not specifying where

23
Q

What is a foreign key?

A

Is a set of attributes in a table that refers to the primary key of another table. The foreign key links these two tables.

24
Q

How do you join two SQL tables?

A

Use the join keyword followed by “tableName” followed by using keyword followed by (“foreign key”);

25
Q

How do you temporarily rename columns or tables in a SQL statement?

A

Use as (e.g table_name as alias_name)