Dbms Short Notes
Dbms Short Notes
Dbms Short Notes
2. Two tier architecture: In two-tier architecture, the Database system is present at the server machine
and the DBMS application is present at the client machine, these two machines are connected with each other
through a reliable network .
Whenever a client machine makes a request to access the database present at the server using a query language
like sql, the server performs the request on the database and returns the result back to the client.
The application connection interfaces such as JDBC, ODBC are used for the interaction between server and
client.
3. Three tier architecture: In three-tier architecture, another layer is present between the client
machine and server machine.
In this architecture, the client application doesn’t communicate directly with the database systems present at
the server machine, rather the client application communicates with the server application and the server
application internally communicates with the database system present at the server.
Q8). Benefits of 3-Tier Architecture?
• Presentation layer − This layer is also called the client layer. The front-end layer consists of a user
interface. The main purpose is to communicate with the application layer.
• Application layer − This layer is also called the business logic layer. It acts as a middle layer between
the client and the database server which are used to exchange partially processed data.
• Database layer − In this layer the data or information is stored. This layer performs operations like
insert, update and delete to connect with the database.
Q10). Definition of Schema?
Schema is the structure of the database that defines the objects in the database.
Q11).Types of Command and Queries ?
2. Unique Key: A unique key, also known as a unique constraint, is a set of one or more columns whose values
uniquely identify each row in a table. It ensures that no two rows can have the same combination of values in
the specified columns. Unique keys can be composed of a single column or multiple columns. They are used to
enforce entity integrity in a database schema.
• It must contain unique values, and no two records can have the same primary key value.
• It ensures that each value in the foreign key column corresponds to an existing value in the primary
key column of the referenced table.
3. Unique Key:
• A unique key ensures that all values in a column or a set of columns are unique, similar to a primary
key.
• Unlike a primary key, a unique key column can contain NULL values (except in SQL Server where it
allows only one NULL value).
4. Composite Key:
• A composite key, also known as a compound key, is a combination of two or more columns that
uniquely identify a record in a table.
5. Alternate Key:
• An alternate key is a candidate key that is not selected as the primary key.
• While a table can have multiple candidate keys, only one of them can be chosen as the primary key.
• Example: If both EmployeeID and EmployeeSSN are unique, but EmployeeID is chosen as the primary
key, then EmployeeSSN becomes an alternate key.
6. Super Key:
A super key is a set of one or more columns (attributes) that, taken together, uniquely identify each
record in a table.
Every primary key is a super key, but not every super key is a primary key.
Example: If a table has columns {EmployeeID, FirstName, LastName}, then {EmployeeID} and
{EmployeeID, FirstName} are both super keys. However, {EmployeeID} is chosen as the primary key.
Q14). Differentiate between Referential Integrity and Entity Integrity?
Referential Integrity:
• Definition: Referential integrity is a database concept that ensures the consistency of relationships between
tables. It enforces that relationships between tables are valid and that foreign key values refer to existing
primary key values in another table.
• Purpose: The purpose of referential integrity is to maintain data integrity and prevent orphaned records,
where a foreign key value refers to a non-existent primary key value in the referenced table.
• Example: In a database with tables for "Orders" and "Customers," referential integrity ensures that every
order must be associated with an existing customer by enforcing that the customer ID in the "Orders" table
must exist in the "Customers" table.
Entity Integrity:
Definition: Entity integrity is a concept that ensures that each row or record in a table is uniquely identifiable and
cannot contain duplicate or null values in its primary key column(s).
• Purpose: The purpose of entity integrity is to maintain uniqueness and accuracy within a table by ensuring
that each record can be uniquely identified and that there are no duplicate or null values in the primary key
column(s).
• Example: In a table for "Employees," entity integrity ensures that each employee record has a unique
employee ID and that the employee ID column cannot contain null values or duplicates.
Constraints:
Definition: Constraints are rules or conditions imposed on data in a database to maintain data integrity and
consistency. They define the allowable values and relationships between data elements.
Clauses:
• Definition: Integrity clauses, often referred to as integrity constraints, are conditions or rules specified within
SQL statements to ensure the integrity of the database.
In summary, keys uniquely identify records within a table and establish relationships between tables, constraints
enforce rules and conditions on data, and clauses specify integrity constraints within SQL statements to ensure data
integrity.
- Examples:
- DDL commands do not directly manipulate data but instead define the schema of the database.
- Examples:
- DML commands directly interact with the data stored in the database.
- Examples:
- COMMIT: Used to save all changes made during the current transaction.
- ROLLBACK: Used to undo all changes made during the current transaction.
- SAVEPOINT: Used to set a point within a transaction to which you can later roll back.
- TCL commands ensure data consistency and integrity by managing the transactional operations performed on the
database.
Q17). select * (asteric sign ?) from student ,why we use star here?
In SQL, the asterisk (*) is used as a wildcard character to represent "all columns" or "every column" in a table. So
when you write SELECT * FROM student, it means you want to retrieve all columns from the "student" table.
• Foreign Key: A foreign key is defined within a table to establish a relationship with another table. It references
the primary key (or unique key) of another table.
• Primary Key: Every table should have a primary key, and it cannot contain NULL values. It uniquely identifies
each record and ensures data integrity.
• Foreign Key: Foreign keys are optional and may or may not be present in a table. They establish relationships
between tables and enforce referential integrity.
Q19).what is constraint?
a constraint is a rule or condition applied to a set of data to enforce data integrity and maintain consistency.
Constraints define limitations or restrictions on the type of data that can be stored in a database table. They ensure
that data adheres to certain rules, thereby preventing invalid or inconsistent data from being entered into the
database.
Example: In a table that stores information about orders, a composite key could be composed of the combination of
(OrderID, ProductID), where each order can contain multiple products but the combination of OrderID and ProductID
uniquely identifies each order item.
Definition: An alternate key, also known as a candidate key, is a column or set of columns in a table that could be
chosen as the primary key but are not. It is a unique key that is not selected as the primary key.
Example: In a table that stores information about employees, both EmployeeID and EmployeeSSN might be unique
columns. If EmployeeID is chosen as the primary key, then EmployeeSSN becomes an alternate key.
Q21). why we use ER Diagrams in DBMS?
Visual Representation
Database Design
Communication
Normalization
Identifying Requirements
Database Maintenance
Database Implementation
• ER diagrams are created based on three basic concepts: entities, attributes and relationships.
Network Model: The network model organizes data into a flexible, interconnected structure resembling a graph,
where records are represented as nodes and relationships as edges. It allows for one-to-many and many-to-many
relationships, enabling efficient data access through pointers or links between records. However, its complexity and
lack of standardized query language limited its adoption compared to the relational model.
Hierarchical Model: The hierarchical model organizes data in a tree-like structure, where each record (or node)
has a single parent and may have multiple children. It represents parent-child relationships hierarchically, with each
level containing related records. While efficient for representing certain types of data, such as organizational
structures, it's rigid and less suited for complex, interconnected data relationships compared to the relational model.
In summary, the entity-relationship model focuses on conceptual modeling and representing relationships between
entities, while other database models such as the relational, network, and hierarchical models have different
structures and emphasize different aspects of data organization and access.