SECTION 7: Databases Flashcards
(29 cards)
What is a database?
A structured collection of data that can be easily accessed, managed, and updated.
What is a flat-file database?
A database that stores all data in a single table.
What is a relational database?
A database with multiple tables linked by relationships.
What is a table (in databases)?
A set of records organised in rows and columns.
What is a field?
A single piece of data (column) in a record.
What is a record?
A collection of related fields (row).
What is a primary key?
A field that uniquely identifies each record in a table.
What is a foreign key?
A field in one table that links to the primary key in another table.
What is data redundancy?
Unnecessary repetition of data.
How do relational databases reduce redundancy?
By storing related data in separate linked tables.
What is SQL?
Structured Query Language – used to create, manage, and query databases.
What does the SELECT statement do?
Retrieves data from a database.
What does the FROM clause do?
Specifies which table to query.
What does the WHERE clause do?
Filters records based on conditions.
What does the AND operator do in SQL?
Returns records where both conditions are true.
What does the OR operator do in SQL?
Returns records where at least one condition is true.
What does the * symbol mean in SQL?
Selects all fields.
Write a sample SQL query to get names of students aged 15.
SELECT name FROM students WHERE age = 15;
Write an SQL query to select name and age from table “people” where city is “London”.
SELECT name, age FROM people WHERE city = ‘London’;
What is a data type in a database?
A classification that specifies the kind of data a field can hold, such as INTEGER, TEXT, DATE, etc.
Why are data types important in databases?
ensure data is stored consistently and help prevent errors by restricting the type of data entered.
What does the ORDER BY clause do in SQL?
It sorts the result set of a query by one or more columns.
What is the difference between ASC and DESC in SQL?
ASC sorts the data in ascending order (default), while DESC sorts it in descending order.
What does the INSERT INTO command do in SQL?
It adds new records to a table.