postgreSQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
A relational database management system that uses SQL query language.
mySQL, Microsoft SQL Server, mariaDB, SQLite, Oracle….etc
What are some advantages of learning a relational database?
- Many problem domains can be modeled well using a relational database; flexibility, you can change the system design after database initially created
- relational databases support good guarantees about data integrity. They can store and modify data in a way that makes data corruption as unlikely as possible
- Sql databases are widely used
What is one way to see if PostgreSQL is running?
The ‘top’ command in the terminal to show all the processes currently running
The command ‘sudo service postgresql status’
What is a database schema?
A collection of tables; acts as a description or blueprint of a database
What is a table?
A list of rows each having the same set of attributes; Tables are used to hold information about the objects to be represented in the database.
What is a row?
An individual record with a unique id
What are some examples of aggregate functions?
avg(), sum(), max()/min(), count()…many others
What is the purpose of a group by clause?
Aggregate functions need a group by clause so it knows with rows to aggregate
What is a foreign key?
The id for a record from another table;
How do you join two SQL tables?
SELECT ,
…
FROM
JOIN USING
How do you temporarily rename columns or tables in a SQL statement?
Alias the columns or table using AS keyword
. AS
How do you delete rows from a database table?
DELETE FROM
WHERE = ;
RETURNING *;
RETURNING statement is optional
How do you accidentally delete all rows from a table?
Use a delete statement without a WHERE clause
How do you update rows in a database table?
UPDATE SET = , SET = , . . . WHERE ;
How do you add a row to a SQL table?
INSERT INTO (, . . .) VALUES (,