Section 7 - Relational databases and SQL Flashcards
What is the concept of a database and relational database?
Database:
- – Collecting information that is organised so it is easily accessible, manageable and updatable.
- – A database with one table is called a flat-file database
Relational database:
— Multiple tables linked together through their key fields
What are the following database concepts: • record • field • primary key • foreign key
- – Records: all the data about one entity shown as rows
- – Fields: a single piece of data shown as columns
- – Primary key: a unique field/identifier for every record
- – Foreign key: a field in a table that is a primary key in another table
Why are relational databases better than flat-file databases?
— Flat file databases have problems of inconsistency and redundancy therefore these issues are solved using relational databases.
- – Inconsistency is data being stored differently in the same table
- – Redundancy is data being stored more than once
How do you retrieve data from tables in databases?
SELECT field(s)
FROM table(s)
WHERE condition
ORDER BY field ASC/DESC
How do you insert data into a table?
INSERT INTO table(fields)
VALUES (values)
How do you delete data in a database?
DELETE FROM table
WHERE field = value
How do you edit data in a database using UPDATE?
UPDATE table
SET field = value
WHERE condition