Resources | Subject Notes | Computer Science
In database design, a single-table database is a simple approach where all the data for a particular entity is stored in a single table. This is suitable for scenarios where the data is not highly complex and doesn't involve many relationships between different entities. This section will guide you through defining a single-table database from given requirements, a key skill for the IGCSE Computer Science 0478 exam.
The first step is to carefully analyze the given requirements. Identify the key pieces of information that need to be stored. These requirements will dictate the columns (attributes) of your table.
Based on the requirements, you need to design the table structure. This involves deciding on the column names and their data types.
Column Name | Data Type | Description |
---|---|---|
{Attribute 1} | {Data Type} | {Description of Attribute 1} |
{Attribute 2} | {Data Type} | {Description of Attribute 2} |
Example: Let's say the requirement is to store information about students in a class. The requirements might include: Student ID, Name, Age, and Course.
In this case, the table design would be:
Column Name | Data Type | Description |
---|---|---|
StudentID | Integer | Unique identifier for each student |
Name | Text | The full name of the student |
Age | Integer | The age of the student |
Course | Text | The course the student is enrolled in |
Every table should have a primary key. The primary key is a column (or a combination of columns) that uniquely identifies each record in the table. In the example above, StudentID
would likely be the primary key.
Choosing the correct data type for each column is important. Common data types include:
Requirement: A library needs to store information about books. The information to be stored includes: Book ID, Title, Author, ISBN, and Publication Year.
Single-Table Database Design:
Column Name | Data Type | Description |
---|---|---|
BookID | Integer | Unique identifier for each book |
Title | Text | The title of the book |
Author | Text | The author of the book |
ISBN | Text | The International Standard Book Number |
PublicationYear | Integer | The year the book was published |
Primary Key: BookID
Designing a single-table database involves understanding the requirements, identifying the necessary attributes, choosing appropriate data types, and defining a primary key. This approach is a fundamental concept in database design and is essential for the IGCSE Computer Science 0478 exam.