SQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
open source relational database management system
What are some advantages of learning a relational database?
widely used.
data is also unlikely to be corrupted
What is one way to see if PostgreSQL is running?
top
sudo service postgresql status
What is a database schema?
A collection of tables is called a schema. the rules for how a data is sorted
What is a table?
Relational databases store data in relations, commonly referred to as tables. A table is a list of rows each having the same set of attributes
What is a row?
A table is a list of rows each having the same set of attributes
each row has a list of attributes
each row has the same list of attributes but they probably will have different values
How do you add a row to a SQL table?
insert into
What is a tuple?
a list of values (for columns) is referred to as a tuple.
example: values (‘Ostrich Pillow’, ‘Feel comfy and cozy!’, 99, ‘self care’)
How do you add multiple rows to a SQL table at once?
example:
insert into “products” (“name”, “description”, “price”, “category”)
values (‘Ostrich Pillow’, ‘Feel comfy and cozy!’, 99, ‘self care’),
(‘Tater Mitts’, ‘Scrub some taters!’, 6, ‘cooking’)
returning *;
How do you get back the row being inserted into a table without a separate select statement?
returning *
How do you update rows in a database table?
update clause
Why is it important to include a where clause in your update statements?
because without that, it will update every row
How do you delete rows from a database table?
delete clause
How do you accidentally delete all rows from a table?
using delete without a where clause
What is a foreign key?
a column that is also represented in another table. these columns match each other and can be used to join other tables together