Database Management System Overview
Database Management System Overview
Views, as virtual tables defined by a query, provide a layer of abstraction by presenting data in a simplified form that can enforce business rules, enhance security by restricting direct access to the underlying tables, and reduce complexity in data retrieval operations . They can simplify complex queries by encapsulating them, allowing users to focus on specific results without exposing the underlying structures . However, views do not store data themselves, meaning they must be computed on demand, potentially impacting performance. Additionally, views do not allow data modification directly if they involve complex resolutions like joins or aggregations .
Functions in SQL are computed values that can be used within SQL queries and cannot perform permanent environmental changes like INSERT or UPDATE operations . They are best suited for calculations or transforming data within a query. Stored procedures are more complex structures that can encapsulate a collection of SQL statements with business logic, capable of modifying the database and interacting with external systems . Stored procedures can return multiple result sets and outputs, interacting robustly with client applications, whereas functions generally offer simpler, inline calculations without side effects .
Normalization is the process of designing a database in such a way that reduces data redundancy and improves data integrity . In 1NF, each entity of a table must have unique or atomic values, ensuring no repeating groups of data . 2NF builds on 1NF by ensuring that all non-key attributes are fully functionally dependent on the primary key, thereby removing partial dependencies . Finally, in 3NF, all non-key attributes must be directly dependent only on the primary key, eliminating transitive dependencies to enhance the table structure further .
An Entity Relationship Diagram (ERD) is a crucial tool in database design that visually represents the relationships between different entities within a database, illustrating entities, attributes, and the logical connections between them . ERDs help designers and stakeholders understand the underlying structure of a database, making it easier to conceptualize and communicate the system's components and interactions before actual implementation. By providing a clear overview, they assist in identifying redundancies and potential issues in the design phase, thereby facilitating more efficient and effective database development and maintenance .
DELETE is a DML command used to remove rows from a table based on a specified condition and allows for data recovery as these operations can be rolled back . DROP is a DDL command that removes an entire table from the database, eliminating all data and structure, with no option for recovery as the changes are auto-committed . TRUNCATE, also a DDL command, deletes all rows from a table but retains the table structure for future use; similar to DROP, TRUNCATE changes are auto-committed and thus cannot be rolled back .
Triggers are special procedures that automatically execute in response to certain events on a table or view, such as INSERT, UPDATE, or DELETE operations, allowing for automated enforcement of business rules and data validations . They can enhance data integrity by ensuring that certain conditions are always met before a transaction is completed. However, excessive use of triggers can impact performance, as each trigger adds additional execution requirements during data manipulation operations, potentially leading to slower transaction times, especially in high-volume environments where numerous triggers may need to be checked and executed .
Primary keys are fields or combinations of fields that uniquely identify each record in a table, ensuring each record is distinct and retrievable without confusion; they must contain unique values and cannot be NULL . Foreign keys are used to establish and enforce links between two tables, referencing a primary key in another table to maintain relational integrity . These keys interact by ensuring that relationships between tables are valid and that operations such as join queries can be performed accurately, thereby preserving the referential integrity across the database schema .
A DBMS, or Database Management System, allows users to organize, restore, and retrieve information about data efficiently and effectively. It manages the database structure and controls access to data, involving systems like MySQL and Oracle . On the other hand, an RDBMS, or Relational Database Management System, is a type of DBMS that is based on the relational model of data, which organizes data into separate interconnected tables using a common column. It allows easy data manipulation and retrieval using Structured Query Language (SQL).
In a relational database, a one-to-one relationship can be implemented by using a primary key in both tables, ensuring each record in one table corresponds to exactly one record in another table; this is often used for extending a record with additional details . A one-to-many relationship is established when a primary key in one table is linked to a foreign key in another table, where one record in the first table corresponds to multiple records in the second; this is the most common relationship and is used in scenarios like customers and their orders . Many-to-many relationships are more complex, usually implemented using a junction table that contains foreign keys referencing the primary keys of the tables involved, enabling multiple associations between rows of each table; a typical use case includes students and courses they can enroll in .
The GROUP BY clause in SQL is used to group records that have the same values in specified columns into summary rows, typically used with aggregation functions such as COUNT, AVG, or SUM to produce summarized data . The ORDER BY clause, however, is used to sort the results of a query in either ascending or descending order based on one or more columns, without modifying the rows themselves . GROUP BY is appropriate when aggregating specific fields to extract summary statistics, whereas ORDER BY is used for organizing results in a meaningful sequence for reporting or analysis .