Dbms Short Notes

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Q1).What is Database & DBMS?

Ans: Database - It is a collection of interrelated data .

These can be stored in the form of tables.

A database can be of any size and varying complexity.

A database may be generated and manipulated manually or it may be computerized.

Database Management System - It is general-purpose software that provides the users


with the processes of defining, constructing and manipulating the database for various
applications.

Q2).File System Vs DBMS:-


Q3).Advantage & Disadvantages of Using DBMS:-
Q4). Drawbacks of using file systems?

Q5). Benefits of Three tier Architecture:-


Q6).Two-Tier Architecture & Three-Tier Database Architecture:-
Q7).What are types of architecture in DBMS?
Ans: 1. Single tier architecture: In this type of architecture, the database is readily available on the client machine,
any request made by client doesn’t require a network connection to perform the action on the database.

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?

The 3-tier architecture in DBMS provides several benefits, including:


• Scalability: The architecture separates the application processing and data
management layers, which allows for easy scalability of each layer
independently.
• Flexibility: The architecture allows for the replacement or upgrade of one layer
without affecting the other layers.
• Security: The architecture provides an additional layer of security, as the data
management tier can be isolated from the application and presentation tiers,
reducing the risk of unauthorized access

Q9). Types of layers in 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 ?

Q12).Unique is a constraint or Unique is a Key?


1. Unique Constraint: In the context of a database, a unique constraint is a rule that ensures that all values
in a column or a set of columns are unique. It prevents duplicate values from being inserted into a column or
set of columns. For example, if a "username" column has a unique constraint, it means that each username
must be unique in the table.

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.

Q13). Types of Keys in DBMS?


1. Primary Key (PK):

• A primary key is a unique identifier for each record in a table.

• It must contain unique values, and no two records can have the same primary key value.

• A primary key column cannot have NULL values.

• Every table in a relational database should have a primary key.

• Example: EmployeeID in an Employee table.

2. Foreign Key (FK):


• A foreign key is a column or a set of columns in a table that refers to the primary key or a unique key
of another table.

• It establishes a relationship between two tables, enforcing referential integrity.

• It ensures that each value in the foreign key column corresponds to an existing value in the primary
key column of the referenced table.

• Example: DepartmentID in an Employee table referencing the DepartmentID primary key in a


Department 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).

• A table can have multiple unique keys.

• Example: EmailAddress in a User table.

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.

• It is useful when no single column can uniquely identify a record.

• Example: Combination of (OrderID, ProductID) in an OrderDetails 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.

• The remaining candidate keys become alternate keys.

• 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.

It can include a single attribute or a combination of multiple attributes.

Unlike a primary key, a super key may contain redundant attributes.

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.

Q15).differentiate between keys, constraints, and clauses?


Keys:
• Definition: In a relational database, a key is a set of one or more columns (attributes) that uniquely identifies
each record (tuple) in a table. Keys play a fundamental role in maintaining data integrity and establishing
relationships between tables.

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.

Q16).DDl & DML & TLC?


It seems like you've mentioned "TLC" which is not a standard term in the context of SQL commands. However, I
assume you might be referring to "TCL," which stands for Transaction Control Language. Let me provide information
on all three:
1. **DDL (Data Definition Language)**:
- DDL is used to define and manage the structure of database objects.

- It includes commands such as CREATE, ALTER, and DROP.

- Examples:

- CREATE TABLE: Used to create a new table in the database.

- ALTER TABLE: Used to modify the structure of an existing table.

- DROP TABLE: Used to delete a table from the database.

- DDL commands do not directly manipulate data but instead define the schema of the database.

2. **DML (Data Manipulation Language)**:


- DML is used to manipulate data stored in the database.

- It includes commands such as SELECT, INSERT, UPDATE, and DELETE.

- Examples:

- SELECT: Used to retrieve data from one or more tables.

- INSERT: Used to add new records to a table.

- UPDATE: Used to modify existing records in a table.

- DELETE: Used to remove records from a table.

- DML commands directly interact with the data stored in the database.

3. **TCL (Transaction Control Language)**:


- TCL is used to manage transactions within a database.

- It includes commands such as COMMIT, ROLLBACK, and SAVEPOINT.

- 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.

Each of these language components serves a distinct purpose in SQL:


- DDL is used for defining and managing the structure of database objects.

- DML is used for manipulating data stored in the database.

- TCL is used for managing transactions and ensuring data consistency.

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.

Q18). difference between primary key and foreign key


• Primary Key: A primary key is defined within the table itself as a column (or set of columns) designated as the
primary key.

• 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.

Q20).Difference between composite key and alternative key?


Definition: A composite key, also known as a compound key, is a combination of two or more columns (attributes)
that together uniquely identify each record in a table. Instead of a single column, multiple columns are used as the
primary key.

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

Q22). What is ER Diagram?


• ER Diagram stands for Entity Relationship Diagram, also known as ERD is a diagram that displays the
relationship of entity sets stored in a database.

• In other words, ER diagrams help to explain the logical structure of databases.

• ER diagrams are created based on three basic concepts: entities, attributes and relationships.

Q23).Define relational model, network model,hierarchical model & entity


relation model?
Relational Model: The relational model organizes data into tables (relations) consisting of rows (tuples) and
columns (attributes), where each row represents a unique record, and each column represents a distinct attribute. It
emphasizes mathematical principles, such as set theory and predicate logic, to ensure data integrity and facilitate
querying through structured query language (SQL).

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.

Q24)hierarchical model advantages and disadvantages ?

Q25). tuple calculus,relation algebra?

Lec-51: Tuple Calculus in DBMS with examples (youtube.com)

(2) Lec-44: Introduction to Relational Algebra | Database Management System - YouTube


I've provided a brief overview of the key points
discussed by the CU faculty. For deeper
understanding, please refer to the professor's
notes or relevant YouTube videos.
( Join My Channel For Notes)

DBMS Notes Link:- DBMS ( Data Base Management System ) (notion.site)


Channel Link:- WhatsApp Channel Invite

You might also like