0% found this document useful (0 votes)
25 views2 pages

Flat File and Relational Databases

Uploaded by

skilzababy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views2 pages

Flat File and Relational Databases

Uploaded by

skilzababy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Flat File and Relational Databases

1. Define a flat file database.


o A database that stores data in a single table or worksheet. (1
Mark)
2. Explain one advantage of using a relational database over a
flat file database.
o Relational databases reduce data redundancy by organizing
data into multiple related tables. (1 Mark)
o They also improve data integrity and make it easier to update
and retrieve data. (1 Mark)
3. What is a primary key?
o A unique identifier for each record in a database table. (1
Mark)
4. Why is it important to have a primary key in a database
table?
o It ensures each record can be uniquely identified. (1 Mark)
o It helps establish relationships between tables. (1 Mark)
5. Describe what a foreign key is in a relational database.
o A field in one table that uniquely identifies a row of another
table or the same table. (1 Mark)
o It is used to establish and enforce a link between the data in
the two tables. (1 Mark)

Questions Based on the Database

1. How many students are enrolled in the Science course?


o 2 students (Eve and Bob). (1 Mark)
2. What is the CourseName for CourseID 101?
o Mathematics (1 Mark)
3. Which student has StudentID 3?
o Carol Johnson (1 Mark)
4. List the FirstName and LastName of all students enrolled in the
English course.
o David Wilson, Frank Miller (2 Marks)

SQL Questions

1. Write an SQL query to retrieve all records from the Students


table.

sql
Copy code
SELECT * FROM Students;

(2 Marks)

2. Write an SQL query to add a new student to the Students


table.
sql
Copy code
INSERT INTO Students (StudentID, FirstName, LastName, DateOfBirth, CourseID)
VALUES (7, 'Grace', 'Lee', '2006-04-15', 101);

(2 Marks)

3. Write an SQL query to update the CourseID for StudentID 2 to


103.

sql
Copy code
UPDATE Students
SET CourseID = 103
WHERE StudentID = 2;

(2 Marks)

4. Write an SQL query to delete the student with StudentID 6


from the Students table.

sql
Copy code
DELETE FROM Students
WHERE StudentID = 6;

(2 Marks)

5. Write an SQL query to retrieve the names of students


enrolled in the Mathematics course.

sql
Copy code
SELECT FirstName, LastName
FROM Students
WHERE CourseID = 101;

(4 Marks)

You might also like