sql Flashcards
What is a flat-file database?
A database made up of one table
What is a relational database?
A database containing more than one table
What is an entity?
a collection of all related records
What is a primary key?
a unique value in a table e.g. teacher_ID
What is a secondary key?
data that can be used for a specific search e.g.teacher_name
What is a foreign key?
a field that references the primary key of another table
What are the 3 types of relationships?
one-to-one
one-to-many
many-to-many
Why is a many-to-many relationship a potential problem?
it will be difficult to reassemble the data
How do you select all the data from a table?
SELECT*
FROM table_name
How do you select specific data from a table?
SELECT attribute1, attribute2
FROM table_name
How do you select data depending on the value of an attribute?
SELECT*
FROM table_name
WHERE attribute=value
How do you order data by ascending order?
SELECT*
FROM table_name
ORDER BY attribute ASC
How do you order data by descending order?
SELECT*
FROM table_name
ORDER BY attribute DESC
How do you select data from 2 tables?
SELECT table1_attribute,
table2_attribute
FROM table1, table2
How do you select data and join 2 tables?
SELECT*
FROM table1, table2
WHERE
table1attribute+table2attribute