Introduction To Database
Introduction To Database
o raw facts, figures, and statistics collected, stored, and processed for various
purposes.
o It can take many forms, including text, numbers, images, audio, and video. Data
can be structured, semi-structured, or unstructured.
- Information
o refers to a type of database architecture where all data is stored and managed in
a single location or server.
- Distributed database
o database that consists of multiple interconnected databases that are spread
across different locations or nodes in a network.
o , data is stored in multiple physical locations but appears to the user as a single,
centralized database
In this scenario, the retail chain utilizes a distributed database to manage its
inventory, sales, and customer information. The distributed database system
consists of multiple nodes, with each node located in a different region where the
retail stores are located.
- Personal database:
o database system designed to be used by an individual to manage and organize
personal data, information, and resources.
o It can serve various purposes, ranging from organizing personal contacts and
schedules to tracking personal finances or storing personal documents.
z
o databases are typically user-friendly and provide simple interfaces for data entry,
retrieval, and manipulation
- commercial database
o database system that is developed, marketed, and sold by a software company
for profit.
Relational database
Tables have many rows of data. Rows are often called records
Tables have many columns. They are labeled with a descriptive
name and have a specific data type.
Sure, let's consider a simple example of a relational database for a library.
1. Books: This table will store information about the books available in the library.
Attributes:
2. Users: This table will store information about the library users.
Attributes:
UserID: Unique identifier for each user.
Name: Name of the user.
Email: Email address of the user.
Address: Address of the user.
Phone: Phone number of the user.
These tables are related through a concept called foreign keys. In our example, we
might have another table, let's call it Borrowings, which tracks which users have
borrowed which books.
Attributes:
BorrowID: Unique identifier for each borrowing.
UserID: Foreign key referencing the UserID in the Users table.
BookID: Foreign key referencing the BookID in the Books table.
BorrowDate: Date the book was borrowed.
ReturnDate: Date the book was returned.
Here's how these tables might look:
Books Table:
Users Table:
Borrowings Table:
In this example, we have a relational database consisting of three tables: Books, Users,
and Borrowings. These tables are related to each other through common keys (BookID,
UserID) which allow us to establish connections and retrieve related information as
needed.
Primary key
A primary key is a unique identifier for each record (or row) in a table. It ensures
that each row in the table can be uniquely identified. Primary keys must satisfy
the following conditions:
o They must contain unique values within the table.
o They cannot contain NULL values.
Foreign key
In this table:
BookIDis the primary key, as it uniquely identifies each book in the table.
Each value in the BookID column is unique, and it cannot contain NULL
values.
Users Table:
In this table:
UserIDis the primary key, uniquely identifying each user in the table.
Each value in the UserID column is unique, and it cannot contain NULL
values.
Borrowings Table:
In this table: