Postgresql Flashcards

1
Q

PostgreSQL

A

is a database management system that uses SQL to interact with the database

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

SQL

A

Standard Structures Query Language

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

Types of data bases

A

Relational and non relational

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

Types of relational databases

A
  1. One-to-one relationship
  2. One-to-Many relationship
  3. Many-to-Many relationship
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Main command types in SQL

A
  1. DDL- data definition language
  2. DCL- data control language
  3. DML- data manipulation language
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

DDL commands

A

Data definition language
- create - create a database, table, temporary user, user
- drop - remove all the data and the structure of column, table and user
- alter - making changes remove, update
- truncate - remove all data in a table

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

DCL commands

A

Data control language
Grant - give privileges
Revoke - remove privileges

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

DML commands

A

Data manipulation language
- Insert - data in a table
- update - any data in a table
- delete - either while data in data base or certain data from table
- select - retrieve data from table

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

Inner join

A

Retuns rows when there is a match in both tables

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

Full join

A

Returns all rows when there is a match in one of the tables

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

Left join

A

Returns all rows from the left table, and the matched rows from the right table

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

Right join

A

Returns all rows from the right table and the matched rows from the left table

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

What does truncate do

A

Removes all of the values inside of a table from the database

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

What does drop do

A

Remove both the content and the structure of the table, database or user

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

What is a constrain

A

Is a rule applied to columns or table in a database to maintain the integrity and accuracy of the data

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

Types of constraints

A

Primary key, foreign key, unique, check, not null, default

17
Q

Data types

A
  • numeric type: int, float, serial
  • character type: text, char(50), varchar(50)
  • data/time type
  • Boolean type
  • json
18
Q

What is alter used for

A
  • add column
  • rename column
  • remove column
  • add constraint
  • remove constraint
19
Q

Distinct formula

A

Select distinct attributename from tablename;

20
Q

Limit formula

A

Select * from tablename LIMIT number;

21
Q

Aggregate functions formula

A

Select aggregate(attributename) from tablename;

AVG(), COUNT(), MIN(), MAX(), and SUM().

22
Q

Ascending, descending formula

A

Select * from tablename ORDER BY attributename ASC/DESC;

23
Q

Comparison operators formula

A

Select * from tablename WHERE attribute operator value;

24
Q

Arithmetic operators formula

A

Select attributename operator value from tablename;

25
Q

Why data validation is important

A

To ensure that data stored in a database is accurate, consistent and meets the specified standards and business rules.

26
Q

Formula to find duplicates

A

Select name, count()
from tablename
group by name
having count(
) >1;

27
Q

Formula of joins

A

Select attribitenames (or*)
from table1
name join table2
on table1.column = table2.column;

28
Q

Difference between char, varchar and text data types

A
  • char - is fixed length character string
  • varchar - is variable length character string
  • text - is large variable length character string