SQL And Databases Flashcards
What is a database?
A database is an organised collection of data that can be easily accessed, managed, and updated.
What is a record in a database?
A record is a single row in a table that contains data about one item.
What is a field in a database?
A field is a column in a table that holds one piece of data about every record.
What is a primary key?
A primary key is a field that uniquely identifies each record in a table. It cannot be duplicated or left empty.
What is a foreign key?
A foreign key is a field in one table that links to the primary key in another table, creating a relationship between the tables.
What is a flat file database?
A database that stores all data in a single table. It is simple but can lead to data redundancy.
What is a relational database?
A database that stores data in multiple related tables, reducing redundancy and improving data integrity.
What is SQL?
SQL (Structured Query Language) is the standard language used to create, modify, and query databases.
What does the SQL SELECT statement do?
It retrieves data from a database.
Example: SELECT name FROM students returns the name field from the students table.
What does the SQL WHERE clause do?
It filters results based on a condition.
Example: SELECT * FROM students WHERE grade = ‘A’ returns only students with grade A.
What does * mean in an SQL query?
It means “select all fields”.
Example: SELECT * FROM students returns every column from the students table.
How do you sort results in SQL?
Use ORDER BY.
Example: SELECT name FROM students ORDER BY age sorts by age.
How do you rename a field in the output using SQL?
Use AS.
Example: SELECT name AS student_name FROM students.
What does the SQL INSERT INTO command do?
It adds new data to a table.
Example: INSERT INTO students (name, grade) VALUES (‘Alice’, ‘A’).
What does the SQL UPDATE command do?
It changes existing data.
Example: UPDATE students SET grade = ‘B’ WHERE name = ‘Alice’.
What does the SQL DELETE command do?
It removes data from a table.
Example: DELETE FROM students WHERE name = ‘Alice’.
Why is validation important in databases?
Validation checks that data entered is sensible and reasonable, improving data integrity and reducing errors.