DBMS Module 1&2
DBMS Module 1&2
1.B-trees
or
or
5. **Clustered/Non-clustered Indexing:**
Organizes records based on key values, affecting
retrieval speed.
or
or
or
4. what you mea by functional dependancy
or
or
or
A trivial dependency in a database is like saying
something obvious or redundant. It's when knowing
one thing automatically tells you something you
already knew.
6. what is normalization
or
or
For example:
- Name field: 20 bytes
- Age field: 2 bytes
- Salary field: 6 bytes
or
or
1. **Hashing:**
- Hashing is like assigning a unique ID to
something based on its characteristics. Imagine
you have a big list of items, and you want to quickly
find a specific item. Hashing helps by converting
the item's characteristics into a unique code (hash
value) that can be used to quickly locate it.
- For example, think of a library organizing books
by their titles. Each book's title is converted into a
unique code (hash value), making it easier to find
the book on the shelf quickly.
2. **Indexing:**
- Indexing is like creating a table of contents for a
book. It's a way of organizing data in a structured
format to speed up searches and access. Instead of
searching through every page of the book (or every
record in a database), indexing provides a roadmap
to quickly locate specific information.
- For instance, in a database, an index is a list of
keys (e.g., IDs, names) and their corresponding
locations in the data. This index helps retrieve data
faster by directly accessing the location where the
desired information is stored, similar to using a
table of contents to find a specific chapter in a
book.
or
Sure, here's a simpler explanation of hashing and
indexing:
1. **Hashing:**
- Hashing is like giving each item a special code
based on its characteristics. This code helps
quickly find the item when needed. It's similar to
how each person has a unique ID number that
identifies them.
2. **Indexing:**
- Indexing is like creating a list of important
information and where to find it. It's like having a
table of contents in a book that tells you which
page has the information you're looking for. In
databases, indexing helps quickly locate specific
data without searching through everything.
or
or
1. **CREATE TABLE:**
- This command is used to create a new table in
the database.
- Example: `CREATE TABLE Employees (ID INT
PRIMARY KEY, Name VARCHAR(50), Age INT);`
2. **ALTER TABLE:**
- This command is used to modify an existing
table structure, such as adding or deleting
columns.
- Example: `ALTER TABLE Employees ADD
COLUMN Salary DECIMAL(10, 2);`
3. **DROP TABLE:**
- This command is used to delete an existing table
from the database.
- Example: `DROP TABLE Employees;`
4. **CREATE INDEX:**
- This command is used to create an index on a
table, which improves the speed of data retrieval
operations.
- Example: `CREATE INDEX idx_name ON
Employees (Name);`
5. **DROP INDEX:**
- This command is used to remove an existing
index from the database.
- Example: `DROP INDEX idx_name;`
6. **CREATE VIEW:**
- This command is used to create a virtual table
based on the result of a SELECT query.
- Example: `CREATE VIEW EmployeeView AS
SELECT ID, Name, Age FROM Employees WHERE
Salary > 50000;`
7. **DROP VIEW:**
- This command is used to delete an existing view
from the database.
- Example: `DROP VIEW EmployeeView;`
8. **CREATE DATABASE:**
- This command is used to create a new database
in the database management system (DBMS).
- Example: `CREATE DATABASE CompanyDB;`
9. **ALTER DATABASE:**
- This command is used to modify an existing
database, such as changing its name or modifying
its settings.
- Example: `ALTER DATABASE CompanyDB
MODIFY NAME = NewCompanyDB;`
2. **Composite Attribute:**
- A composite attribute is composed of multiple
simple attributes. It can be divided into smaller
parts. For example, an "Address" attribute might
include sub-attributes like "Street," "City," "State,"
and "Zip Code."
3. **Derived Attribute:**
- A derived attribute is derived or calculated from
other attributes in the table. It does not store data
directly but is derived using a formula or
computation. For example, a "Total Price" attribute
in an invoice table calculated from the "Unit Price"
and "Quantity" attributes.
4. **Key Attribute:**
- A key attribute uniquely identifies each record or
entity in a table. It is used to establish relationships
between tables. For example, a "Student ID"
attribute in a student table.
5. **Composite Key:**
- A composite key is a combination of multiple key
attributes that together uniquely identify each
record in a table. For example, a combination of
"Employee ID" and "Department ID" as a composite
key in an employee table.
6. **Foreign Key:**
- A foreign key is an attribute in a table that refers
to the primary key of another table. It establishes
relationships between tables. For example, an
"Order ID" attribute in an order details table that
references the "Order ID" in the orders table.
7. **Null Attribute:**
- A null attribute is one that can have a null or
missing value. It represents an unknown or
undefined value for an attribute. For example, an
"Email" attribute in a customer table that may be
null if the customer has not provided an email
address.
or
- **Examples:**
- `SELECT * FROM Employees WHERE Name LIKE
'John%';` - Finds names starting with 'John'.
- `SELECT * FROM Products WHERE ProductName
LIKE '_pple%';` - Finds products with names like
'Apple', 'Zpple', etc.
1. **Primary Key:**
- A primary key is a unique identifier for each
record in a table.
- It ensures that each record is distinct and can
be uniquely identified.
- Example: In a "Students" table, the "Student ID"
column can be a primary key.
2. **Foreign Key:**
- A foreign key is a field in one table that refers to
the primary key in another table.
- It establishes a relationship between two tables
based on a common column.
- Example: In an "Orders" table, the "Customer ID"
column can be a foreign key that references the
"Customer ID" primary key in a "Customers" table.
or
1. **Primary Key:**
- It's like a special ID for each record in a table.
- It ensures every record is unique and easy to
identify.
2. **Foreign Key:**
- It's like a connection between two tables.
- It links one table's ID to another table's ID to
show a relationship between them.
1. **Physical Level:**
- This is the lowest level of abstraction.
- It deals with how data is stored physically on the
storage devices such as hard disks.
- It includes details like data storage format,
access methods, indexing, etc.
2. **Logical Level:**
- This is the middle level of abstraction.
- It deals with how data is viewed and accessed
by users or applications.
- It includes defining tables, views, indexes,
constraints, and relationships without worrying
about physical storage details.
1. **Entities:**
- Represent real-world objects or concepts, such
as a person, place, thing, or event.
- Shown as rectangles in the diagram, with the
entity name inside.
- Example: "Customer," "Product," "Order."
2. **Attributes:**
- Descriptive properties or characteristics of
entities.
- Represented as ovals connected to their
respective entities.
- Example: In the "Customer" entity, attributes
could include "CustomerID," "Name," "Email."
3. **Relationships:**
- Describes how entities are related to each other.
- Represented as diamond shapes connecting
related entities.
- Example: A "Customer" places an "Order," which
is a relationship between the "Customer" and
"Order" entities.
6. **Constraints:**
- Rules or conditions that must be followed to
maintain data integrity.
- Examples include uniqueness constraints,
referential integrity constraints, etc.
or
Example:
```sql
INSERT INTO Customers (CustomerID, Name, Email)
VALUES (1, 'John Doe', '[email protected]');
```
or