0% found this document useful (0 votes)
7 views

Report

User data

Uploaded by

prashanthkapu491
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)
7 views

Report

User data

Uploaded by

prashanthkapu491
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/ 5

21INT49-Internship Report

Chapter 5

DBMS
A Database Management System (DBMS) serves as a fundamental component in
modern information systems, facilitating the storage, retrieval, and management of data
in a structured and organized manner. It acts as an intermediary between users and the
database, enabling efficient access to data while ensuring data integrity, security, and
concurrency control. DBMS software handles tasks such as data modeling, schema
definition, query processing, optimization, and transaction management, providing
users with a unified interface to interact with the underlying database.

One of the key advantages of a DBMS is its ability to support multiple users and
applications concurrently, allowing for collaborative data access and manipulation
without compromising data consistency or reliability. By enforcing ACID (Atomicity,
Consistency, Isolation, Durability) properties, DBMS ensures that transactions are
processed reliably and efficiently, even in the presence of concurrent access and
system failures. Additionally, DBMS often incorporates features such as data backup
and recovery, replication, and access control mechanisms to safeguard data integrity
and protect against unauthorized access or data loss.

5.1 Structured Query Language (SQL)

SQL (Structured Query Language) queries form the backbone of interacting with
relational database management systems (RDBMS) in database management systems
(DBMS). They allow users to perform various operations such as retrieving, manipulating,
and managing data stored in a relational database. Here's an overview of SQL queries in
DBMS:

Data Retrieval:

 SELECT statement: Used to retrieve data from one or more tables based on
specified criteria.

 FROM clause: Specifies the table(s) from which data is to be retrieved.

 WHERE clause: Filters data based on specified conditions.

 JOIN operations: Combines data from multiple tables based on related columns.

Department of CSE, SIT, Mangaluru Page 16


21INT49-Internship Report

Data Manipulation:

 INSERT statement: Adds new records into a table.

 UPDATE statement: Modifies existing records in a table based on specified


conditions.

 DELETE statement: Removes records from a table based on specified conditions.

Data Definition:

 CREATE statement: Creates new database objects such as tables, views, indexes, or
stored procedures.

 ALTER statement: Modifies the structure of existing database objects.

 DROP statement: Deletes database objects such as tables, views, or indexes.

Data Control:

 GRANT statement: Assigns privileges to users or roles, allowing them to perform


specific actions on database objects.

 REVOKE statement: Removes previously granted privileges from users or roles.

Transaction Control:

 BEGIN TRANSACTION statement: Starts a new transaction.

 COMMIT statement: Commits a transaction, making its changes permanent.

 ROLLBACK statement: Rolls back a transaction, undoing its changes.

Data Querying and Aggregation:

 Aggregate functions (e.g., SUM, AVG, MAX, MIN, COUNT): Performs


calculations on sets of values.

 GROUP BY clause: Groups rows based on specified columns.

 HAVING clause: Filters groups based on specified conditions.

 ORDER BY clause: Sorts the result set based on specified columns.

Department of CSE, SIT, Mangaluru Page 17


21INT49-Internship Report

5.2 Creating database

Creating a database in SQL involves using the CREATE DATABASE statement followed by
the name of the database you wish to create. For example:

CREATE DATABASE my_databases;

This statement creates a new database named "my_database" in the SQL server. Once
created, you can then proceed to create tables, define relationships, and manage data within
this database using SQL statements. It's worth noting that depending on the SQL
implementation (e.g., MySQL, PostgreSQL, SQL Server), additional options such as
specifying character sets, collations, and storage configurations may be available when
creating databases.

5.3 SQL queries with table

Data Types:

Data types define the type of data that can be stored in a column of a table. Common data
types include:

 Numeric types (e.g., INTEGER, DECIMAL, FLOAT)

 Character types (e.g., CHAR, VARCHAR, TEXT)

 Date and time types (e.g., DATE, TIME, TIMESTAMP)

 Binary types (e.g., BINARY, VARBINARY, BLOB).

Constraints:

Constraints are rules enforced on data within a table to maintain data integrity.Common
constraints include:

 Primary Key: Ensures each row in a table is uniquely identified.

 Foreign Key: Enforces referential integrity between two tables by


requiring values in one table to match values in another table's primary
key.

 Unique: Ensures that values in a column (or a combination of columns)


are unique across the table.

Department of CSE, SIT, Mangaluru Page 18


21INT49-Internship Report

 NOT NULL: Specifies that a column must have a non-null value.

 Check: Enforces specific conditions on values allowed in a column.

Default Value:

Default values provide a predetermined value for a column if no value is explicitly


specified during insertion.

 When defining a column, you can specify a default value using the
DEFAULT constraint.

 Default values can be constants, expressions, or special values such as


NULL or CURRENT_TIMESTAMP.

5.4 Creating Table


Creating a table in a Database Management System (DBMS) involves defining the structure
of the table, including its columns and the data types they will contain. This process is
fundamental for organizing and storing data efficiently within a database. In SQL, the
standard language for managing relational databases, the CREATE TABLE statement is used
to create tables.
CREATE TABLE table_name (
column1 datatype [constraints],
column2 datatype [constraints],
...
[table_constraints]
);

5.5 Database Relationsips:

Database relationships in DBMS are fundamental for organizing and managing data
effectively. These relationships define how data in one table is associated with data in another
table, ensuring data integrity and consistency within the database.

In a one-to-one relationship, each record in the parent table corresponds to exactly one
record in the child table, and vice versa. While this relationship is less common, it's useful for
separating distinct data entities when necessary.

Department of CSE, SIT, Mangaluru Page 19


21INT49-Internship Report

A one-to-many relationship is more prevalent, where each record in the parent table can be
linked to multiple records in the child table, but each record in the child table is associated
with only one record in the parent table. This model is often used to represent hierarchical
structures or scenarios where one entity has multiple related entities.

Many-to-many relationships occur when each record in one table can be related to multiple
records in another table, and vice versa. In such cases, a junction table is used to establish the
connection between the two tables, containing foreign key columns that reference the primary
keys of the related tables.

For instance, in a school database, a one-to-many relationship may exist between Students
and Courses tables, where each student can enroll in multiple courses, but each course is
associated with only one student. Additionally, a many-to-many relationship can exist
between Students and Courses tables, as each student can enroll in multiple courses, and each
course can have multiple students enrolled.

These relationships ensure data consistency, prevent redundancy, and enable efficient data
retrieval and manipulation, making them essential in designing robust and scalable database
schemas.

5.6 Conclusion

In conclusion, Database Management Systems (DBMS) serve as foundational components in


modern information systems, facilitating the storage, organization, and retrieval of vast
amounts of data efficiently. DBMS enables users to interact with databases using Structured
Query Language (SQL) or other query languages, allowing for seamless data manipulation,
querying, and management.

The importance of DBMS lies in its ability to ensure data integrity, security, and concurrency
control, thereby maintaining consistency and reliability in data operations. By enforcing
constraints, establishing relationships between data entities, and providing mechanisms for
transaction management, DBMS ensures that data remains accurate, accessible, and protected
from unauthorized access or corruption.

Department of CSE, SIT, Mangaluru Page 20

You might also like