S7 Relational Databases and SQL Flashcards
What is a database?
A way of holding data in an organised way so that it is quick and and easy to find a particular item, or all the items meeting a certain criteria. It contains one or more tables.
What sections does a table have?
rows, records, fields, columns
What is a primary key
A unique identifier (no 2 records will have the same)
What happens in a relational database?
Each entity has its own table, and the tables are linked by a common field
What are the advantages of using a relational database?
Elimination of data inconsistency and data redundancy.
What is a foreign key?
A field which is a primary key in a linked table.
What are the 3 possible relationships between tables?
One-to-one, one-to-many, many-to-many
What is SQL used for?
Querying and updating tables in a relational database.
What is the syntax for a SELECT statement?
SELECT list, of, fields, to, be, displayed
FROM list the table/s where the data will come from
WHERE list = “of search criteria”
ORDER BY order of results default = ascending
How are dates portrayed in SQL
BETWEEN #01/01/2019# AND #31/12/2019#
What phrase do you need to use when querying 2 tables?
WHERE (Table1. Primary key = Table2. foriegn key)
What syntax is used for a INSERT INTO statement?
INSERT INTO tableName (column1, column2,…)
VALUES (value1, value 2,…)
NOTE: If all the fields are being added in the correct order, it is not necessary to specify the field names.
What syntax is used for an UPDATE statement?
UPDATE tableName
SET column1 = value1, column2 = value2,…
WHERE column = value
What syntax is used for a DELETE statement?
DELETE FROM tableName
WHERE column = value