Class 12 Computer Important Questions and answer, chapter 1, Database
Chapter 1:
1. Explain relational data model.
The relational data model is a method of organizing data into tables, where each table represents a collection of related entities or facts. This model is based on mathematical set theory and logic, offering a structured approach to storing and managing data in database systems. In the relational model:
Tables: Data is organized into tables, also known as relations, where each table consists of rows and columns. Each row represents a single record or instance of an entity, while each column represents a specific attribute or property of that entity.
Attributes and Entities: Tables contain attributes, which define the properties of the entities being represented. Entities are the objects or concepts being modeled, and each entity is represented by a table in the database.
Relationships: Relationships between entities are established through keys. Primary keys uniquely identify each row in a table, while foreign keys establish relationships between tables by referencing the primary keys of other tables.
In a relational database table, relationships between entities are typically represented using primary and foreign keys. Let's illustrate this with an example of two tables: STUDENT and COURSE.
STUDENT Table:
| ROLL_NO | NAME | COURSE_ID |
|---|---|---|
| 1 | Alice | 101 |
| 2 | Bob | 102 |
| 3 | Charlie | 103 |
| 4 | David | 102 |
COURSE Table:
| COURSE_ID | COURSE_NAME |
|---|---|
| 101 | Math |
| 102 | Science |
| 103 | History |
In the STUDENT table, the COURSE_ID column serves as a foreign key that establishes a relationship with the COURSE table's primary key, COURSE_ID. Each student's COURSE_ID corresponds to a specific course they are enrolled in. For example, Alice is enrolled in the course with the COURSE_ID 101, which corresponds to the "Math" course in the COURSE table.
This relationship allows for the retrieval of information about students and their associated courses, enabling queries like finding all students enrolled in a particular course or retrieving details about the courses taken by a specific student.
2. Demonstrate any two DDL statements with examples.
DDL (Data Definition Language) statements are used to define, modify, and manage the structure of database objects such as tables, indexes, and constraints. Here are two examples of DDL statements:
CREATE TABLE:
This statement is used to create a new table in the database. Here's an example of creating a table named "Students" with columns for student ID, name, age, and grade:
CREATE TABLE Students ( student_id INT PRIMARY KEY, name VARCHAR(50), age INT, grade VARCHAR(2));In this example:
CREATE TABLEis the DDL command to create a new table.Studentsis the name of the table being created.(student_id INT PRIMARY KEY, name VARCHAR(50), age INT, grade VARCHAR(2))defines the columns of the table along with their data types and constraints. Here,student_idis defined as the primary key.
ALTER TABLE:
This statement is used to modify an existing table, such as adding, modifying, or dropping columns.
ALTER TABLE Students ADD COLUMN email VARCHAR(100);In this example:
ALTER TABLE Studentsspecifies the table to be modified.ADD COLUMN email VARCHAR(100)adds a new column named "email" with a VARCHAR data type of length 100 to the "Students" table.
These DDL statements are fundamental in defining the structure of database objects, allowing for the creation, modification, and maintenance of databases in SQL-based systems.
3. Explain role of DBA.
A Database Administrator (DBA) is a professional responsible for managing and maintaining a database system. They ensure that the database operates smoothly, securely, and efficiently to meet the needs of the organization.
Roles of a DBA:
Designing Databases: DBAs create the structure and layout of databases, determining how data will be organized and stored.
Setting Up Databases: They install and configure database software on servers, making sure it runs properly and is optimized for performance.
Securing Data: DBAs implement security measures to protect the database from unauthorized access, ensuring that only authorized users can view or modify data.
Backing Up Data: They regularly back up the database to prevent data loss in case of hardware failures, disasters, or other emergencies.
Monitoring Performance: DBAs keep an eye on the database's performance, identifying and fixing any issues that could slow down operations or cause problems for users.
Normalization is a process used in database management systems (DBMS) to organize data efficiently and reduce redundancy. It involves breaking down larger tables into smaller ones and establishing relationships between them. The primary goal of normalization is to minimize data redundancy and dependency, ensuring data integrity and reducing the likelihood of anomalies during database operations.
Now, let's briefly explain the concepts of 1NF, 2NF, and 3NF with simple examples:
In 1NF, each column in a table contains atomic (indivisible) values, and there are no repeating groups of columns. It eliminates duplicate rows and ensures each row uniquely identifies an entity. For example, consider a table named STUDENT with columns for Student ID (Primary Key), Student Name, and Courses:
Student ID Student Name Courses 1 Alice Math, Physics 2 Bob Chemistry To convert this to 1NF, we break down the repeating group "Courses" into separate rows:
Student ID Student Name Course 1 Alice Math 1 Alice Physics 2 Bob Chemistry Second Normal Form (2NF): In 2NF, the table is in 1NF, and all attributes (columns) are fully functionally dependent on the primary key. If any column depends on only part of the primary key, it's moved to a separate table. For example, consider the following table with Student ID and Course ID as the composite primary key:
Student ID Student Name Course ID Course Name 1 Alice 101 Math 1 Alice 102 Physics 2 Bob 103 Chemistry To achieve 2NF, we split this table into two: STUDENT and COURSE, with Student ID as the primary key in the STUDENT table:
STUDENT Table:
Student ID Student Name 1 Alice 2 Bob COURSE Table:
Course ID Course Name 101 Math 102 Physics 103 Chemistry Third Normal Form (3NF): In 3NF, the table is in 2NF, and there are no transitive dependencies. That is, non-key attributes should depend only on the primary key, not on other non-key attributes. For example, consider a table with Student ID, Course ID, and Instructor:
Student ID Course ID Instructor 1 101 Smith 1 102 Johnson 2 103 Smith To achieve 3NF, we remove the transitive dependency by moving the Instructor to a separate table:
STUDENT_COURSE Table:
Student ID Course ID 1 101 1 102 2 103 INSTRUCTOR Table:
Course ID Instructor 101 Smith 102 Johnson 103 Smith
By following the normalization process, we ensure efficient data storage, minimize redundancy, and maintain data integrity within the database.
5. What is SQL? Describe DML with an example.
SQL (Structured Query Language) is a standard programming language used to manage and manipulate relational databases. It allows users to perform various operations such as querying data, inserting new records, updating existing records, and deleting records from databases.
DML (Data Manipulation Language) is a subset of SQL that focuses on manipulating data within the database. It consists of commands like INSERT, UPDATE, DELETE, and SELECT. These commands enable users to add, modify, and delete data in database tables.
Here's an example of each DML command:
INSERT: The INSERT statement is used to add new records into a database table. For instance, suppose we have a table named STUDENTS with columns for Student ID, Name, and Age. We can insert a new record into this table as follows:
This statement inserts a new record with a StudentID of 1, Name of 'Alice', and Age of 20 into the STUDENTS table.
UPDATE: The UPDATE statement is used to modify existing records in a database table. For example, if we want to update the age of a student named 'Alice', we can use the following statement:
UPDATE STUDENTSSET Age = 21WHERE Name = 'Alice';
This statement updates the age of the student whose name is 'Alice' to 21 in the STUDENTS table.
DELETE: The DELETE statement is used to remove records from a database table. If we want to delete a student record with a StudentID of 1 from the STUDENTS table, we can use the following statement:
DELETE FROM STUDENTS WHERE StudentID = 1;This statement deletes the record with a StudentID of 1 from the STUDENTS table.
SELECT: The SELECT statement is used to retrieve data from one or more tables in a database. For instance, if we want to retrieve the names of all students from the STUDENTS table, we can use the following statement:
SELECT Name FROM STUDENTS;This statement selects the Name column from the STUDENTS table, returning a list of all student names.
Netra Koirala
Computer Science Educator
Passionate computer science educator and author. Provides free study notes, practical guides, and tutorials for Class 9, 10, 11, 12, and B.Sc CSIT students in Nepal. Years of teaching experience in computer science fundamentals.
LinkedIn ProfileRelated Posts
Loading related posts…
Computer Science notes, tutorials, MCQs, and educational resources for Nepal students. Covering Class 9, SEE preparation, Class 11, Class 12, SLC, programming, DBMS, networking, HTML, JavaScript, PHP, OOP and more.
Featured Post
Grade 10 Computer Science: Specification Grid & Model Questions
Specification Grid & Model Questions of Computer Science | Grade 10 📚 Examination Resource Specification Grid & M...