Databases Flashcards
What is PostgreSQL and what are some alternative relational databases?
A relational database
-Oracle, MySQL, SQL server by Microsoft
What are some advantages of learning a relational database?
Doesn’t require a complex structure.
Data integrity – they can store and modify data in a way that makes data corruption as unlikely as possible.
Used frequently.
All relational databases share the same syntax–if you learn one, you can easily learn another one.
Data that’s stored in them can be compacted really well.
Prevent data replication (also good for data integrity)
Information is easy to access. Data is stored in tables and the tables can be joined together in any way that you need to. (flexible based on what your need is).
What is one way to see if PostgreSQL is running?
sudo service postgresql status
top command
What’s the difference between pgweb and postgreSQL?
pgweb is a gui. It’s the graphical interface for postgreSQL.
you need postgreSQL for pgweb. But, you don’t need pgweb for postgreSQL.
What is a database schema?
A collection of tables. Defines how the data in a relational database should be organized..
Defines the structure
What is a table?
A list of rows, each having the same set of attributes.
Attributes are commonly referred to as columns. You might visualize a database table as a sort of spreadsheet where each row is a record in that spreadsheet.
What is a row?
Each row in a table is a single record of data. One instance of each attribute in the table
What is SQL and how is it different from languages like JavaScript?
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.
JS is an imperative language –> you tell it what you want and how to do it.
How do you retrieve specific columns from a database table?
select “columnName”,
“columnName2”
from “tableName”;
How do you filter rows based on some specific criteria?
where “columnName” = ‘criteria’
can use any logical operator
What are the benefits of formatting your SQL?
cleaner and easier to read
What are four comparison operators that can be used in a where clause?
=
!=
<
>
How do you limit the number of rows returned in a result set?
limit number
How do you retrieve all columns from a database table?
select *
How do you control the sort order of a result set?
order by
default is to sort in ascending order
ex) order by “price” desc