7 - Databases Flashcards
What is a database? What is the difference between a (flat file) database and a relational database?
-permanent structured collections of data
-a flat file database has only one table, while a relational database has 2 or more tables that are related by foreign keys
What is a table in a database?
all of the data about a defined group of things structured with fields (columns) and records (rows)
a database can contain more than one table (that is a relational database)
Define a record:
all of the data about one particular object (as a row) in a table
both begin with r
Define a field:
a category within a table (as a column)
What are primary keys? Give some examples:
a unique identifier for each record in a table (e.g. a car number plate, website name, emails)
Define a foreign key:
the primary key from another table used to create a relationship between them
Name 4 ways in which tables in a relational database can be linked:
1:1
many:many
1:many
many:1
The example below is a 1:many
Why might you want to use a relational database?
reduces data inconsistency (data is different in different places) and redundancy (repeated data)
What does SQL stand for?
Structured Query Language
What is the select...from...
command used for?
specifies the field(s) from the specified table(s) to be included in the displayed output table
What is the where
command used for?
specifies certain conditions that need to be met to filter the displayed output data
How do you put 2 where
conditions after one another?
where [condition 1] and [condition 2] ... and [condition n]
How can you make a link between 2 tables in a relational database?
where table1.primaryKey = table2.foreignKey
primaryKey and foreignKey should be the same word/phrase in the two tables
How do you order data in SQL?
STOP FORGETTING THE FIELD NAME
order by [field name] asc/desc
What does the insert
command do? Give an example:
-inserts a new record into a table
insert into [table name] (field1, field2...) values (value1, value2...)
You don’t have to give a specific field
In field 1, the new record will contain value 1