Data Ass
Data Ass
1.Database schema:
Is a blueprint or architecture that defines the structure of a database. It outlines how data is organized in a
database. It includes the tables, fields, data type, relationship, and constraints that dictate how data can be
stored and accessed.
Database schemas can be categorized into several types, each serving different
purposes and structures. Here are the main types:
1. Physical Schema
- Definition: Represents how data is physically stored in the database, including
file structures, indexing methods, and storage paths.
- Usage: Optimizes performance and storage efficiency.
2. Logical Schema**
- Definition: Describes the logical structure of the database, including tables,
fields, relationships, and constraints, without concern for physical storage.
- Usage: Provides a high-level view of the database structure, guiding database
design.
3. Conceptual Schema
- Definition: Offers a community view of the entire database, focusing on the
overall organization of data and its relationships, independent of how it is
implemented.
- Usage: Useful for understanding the data requirements of an organization and
for communication among stakeholders.
4. External Schema (View Schema)
- Definition: Represents how different users or applications view the data. It
defines various user views and access rights.
-Usage: Provides security and data abstraction, allowing users to interact with a
subset of the database without exposing the entire schema.
5. Star Schema
- Definition: A type of data warehouse schema characterized by a central fact
table connected to multiple dimension tables.
- Usage: Optimizes query performance and simplifies data retrieval for analytical
purposes.
Here’s a breakdown of the main components of a database as follows: -
i. Tablets; The fundamental building block of a database schema. Each table contains
rows(records) and columns (fields).
ii. Columns; Each column in a table has a specific data type (e.g., integer, string, date) and
constraints (e.g., NOT NULL, UNIQUE).
iv. Primary key; A unique identifier for each row in a table. It ensures that each record can be
uniquely identified.
v. Foreign key; Afield (collection of fields) in one table that refers to the primary key in another
table, establishing a relationship between two tables.
vi. Relationships; Defines how table are related to each other. Common types include: -
- Many-to-many: Records in table A can be related to multiple records in table B and vice
versa, often managed with a junction table
vii. Indexes; Special data structure that improve the speed of data retrieval operation on a database
table at the cost of additional space and maintenance overhead.
2. Relationships:
- Establishes how tables are related to each other (e.g., one-to-many, many-
to-many).
- Uses primary and foreign keys to enforce these relationships.
3. Constraints:
- Enforces rules on the data to maintain integrity, such as:
- NOT NULL: Ensures a field cannot be left empty.
- UNIQUE: Ensures all values in a column are distinct.
- CHECK: Validates that data meets specific conditions.
4. Normalization:
- Organizes data to reduce redundancy and improve data integrity.
- Involves dividing larger tables into smaller ones and defining
relationships.
5. Scalability:
- Designed to accommodate growth in data volume without significant
redesign.
- Supports efficient indexing and partitioning strategies.
. Consider some examples of database schema as follows;
. Books
-BookID (primary key, INT)
-Title (VARCHAR)
-Author ID (Foreign key, INT)
-Published Year (YEAR)
-Price (DECIMAL)
. Authors
-Author ID (primary key, INT)
-Name (VARCHAR)
-Order Date (INT)
. Order Details
-Order Detail ID (primary key, INT)
-Order ID (foreign key, int)
-Book ID (foreign, INT)
-Quantity (INT)
. orders
-Order ID (primary key, INT)
-Customer ID (foreign key, INT)
-order date (DATE)
. Customers
-customer ID (primary key, INT)
-First name (VARCHAR)
-Last name (VARCHAR)
-Email (VARCHAR)
Due to above example, we are able to prepare some relationships among them as follows: -
-Books to Author: One-to-Many (an author can write multiple books).
-Order to customers: Many-to-One (a customer can have multiple order).
-Orders to order details: One-to-Many (an order can have multiple items).
-Books to order details: Many-to-one (a book can appear in multiple orders).
By concluding;
A well-defined database schema is crucial for efficient data management and retrieval. It helps
data integrity and relationships making it easier to build and maintain applications that rely on
that data.
2.Schema Diagram:
Is a visually represent the structure of a database, including its tables, column, relationships, and
constraints. It helps in understanding how data is organized and how different entities interact
with each other.
A schema diagram shows how entities, attributes, and relationships are connected within a
database. It typically uses a set of symbols to represent different database objects, such as;
. Rectangles; Represent tables.
. Lines: Represent relationships between tables.
. Diamonds: Represent entities.
Schema diagrams can help analysts understand: Relationships between tables, Unique identifiers
for individual entries in a table, and keys to join on.
A schema diagram is seem as having different types possessed, let’s consider some different
types of a schema diagram as follows: -
. Schematic diagrams; A graphical representation of a plan or a model.
. Writing diagrams; A simplified convectional pictorial representation of an electrical circuit.
. Block diagrams; A graphical representation of a system, project, or scenario.
. Pictorial diagrams; Uses picture to represent the different components of a particular system.
. Single-line diagram; A simplified representation of an electrical system.
The following are detailed description of what a schema diagram typically includes:
i. Table: Represented as rectangles, each table contains;
ii. Primary key: Uniquely identify each record in a table. Typically shown as underlined
text.
iii. Foreign key: Establish relationships between tables. Usually represented with connecting
line to the primary key in another table.
iv. Relationship: Lines connecting tables that illustrate how they are related. These can
include;
-One-to-one; A single line connecting two tables, often with a “1” on both ends.
-One-to-many; A line with a 1 on one end and an “N” (or an asterisk) on the other.
Indicating one record in the first table can relate to multiple records in the second.
v. Cardinality: Sometimes shown near the lines to indicate the nature of the relationships
(e.g., 1:1. 1: N, N:M).
BY concluding;
A sch ema diagram is essential for database design, as it is visually maps out the structure and
relationships within the database. It is aids in understanding how data interacts, making it easier
for developers and database administrators to manage and query the data effectively if you need
specific tools or method to create such diagrams.
3.Database instance:
Refers to a specific set of data stored in a database at particular moment in a time. It represents
the actuary data that resides in the database tables and is created base on the database schema.
Also is characterized by its ability to store and manage data, typical adhering to the “ACID”
properties (Atomicity, Consistency, Isolation, and Durability), which ensure reliable transactions,
alongside features like defined schema structures, and the capability to perform complex queries
on the stored data. Essential, a database instance represents a running version of a database
schema with live, Accessible data at a particular moment.
A database instance can be categorized based on their deployment environment, workload
optimization, and database technology used, such as: Cloud-based instances (like AWS RDS),
on-premise instances, cluster instances, compute-optimized instances, and storage optimized
instances.
Different types of database instance based on optimization as follows; -
- General purposes:
Suitable for most standard workloads with balanced CPU, memory, and storage
requirements.
- Memory optimized:
Designed for application that require high speed data access and large amounts of RAM,
like in-memory database.
- Compute optimized:
Prioritizes CPU power for heavy processing tasks like complex queries or data
transformations.
- Storage optimized:
Ideal for large data volumes with frequent read/write operations, focusing on high storage
capacity.
Consider some breakdown of the key concepts of database instance as follows;
i. Data representation:
-A database instance consists of the actual data entries in the table defined by the schema.
Each table in the database can contain multiple rows (records) that represent real-world
entities.
v. Database management:
-Database instance is managed by a DBMS, which ensures data integrity, handles,
transactions, and provides mechanisms for querying and manipulating the data.
x. Transaction:
-A set of operations treated as single unit, ensuring data integrity by either committing all
changes or rolling back to the previous state if an error occurs.
xi. Functionality:
-A database instance represents complete, operational database environment, allowing
applications to access and interact with data.
xii. Components:
-It includes the database management system software, the database schema (table
structure), stored procedures, and other related features.
. Cloud deployment:
-Many database providers offer cloud-based database instance, where the database runs
on a remote server managed by the cloud provider.
- Microsoft SQL server instance: A single instance of the SQL server database management
system running on a server.
- On-premise database instance: A database running on a physical server within an
organization’s data center.
Apart from the advantages of the database instance also there is a lot of
consequences coming from the database instance, let consider some key
points consequence of the database instance as follows: -
4.Architecture of a database
-Refers to the overall design and structure of a database system, outlining how data
is stored, organized, accessed, and managed within it, including the relationship
between data, the rules for manipulating it, and the physical and logical
components that make up the system. Essentially, it’s the blueprint for how a
database functions and interact with applications.
Architecture of a database can be classified into three types as follows:
i. Single-tier architecture
-All components of database management system (DBMS) are on a single server
or platform. Allowing users to access the database directly.
User-centric:
- This level is designed to present data in a way that is most relevant and
understandable for each user, allowing them to access only the data they
require.
Views:
- Views are the primary mechanism used at external level, which are
virtual tables that provide a specific subset of data of data from the
database based on user requirement.
Data independence:
- The external level enables logical data independence, meaning changes to
the underlying database structure (conceptual or internal level) can be
made without affecting the user’s view of the data.
Characteristics;
-multiple user view can exist at this level, tailored to the specific needs of different
users or applications.
-Each view can present different perspective of the data, showing only the relevant
information for each user while hiding the underlying complexities.
-This level includes various external schemas, which define what data is visible to
users and how it is formatted.
-The external level hides the rest of the database from a user group, allowing them
to access only the part they are interested in.
-Users do not need to know the data base schema details, such as the data structure
or table definition.
-The external level is the topmost layer of the three-level architecture of a database
management (DBMS).
-The external level retrieves data from the database by mapping the conceptual and
internal level.
Example:
In a library database, a librarian might see detailed information on about books,
including availability and location, while a borrower might only see titles and
authors.
. A sale person might only see customer details, order history, and product
information relevant to their sales territory.
. The finance department might access a view showing financial transactions,
invoices, and payment details.
. Administrator may have access to the full database schema, including user details
and system configurations.
Business-oriented:
-The conceptual model reflects real-world business concepts and requirements,
making it easier for non-technical users to understand the data structure.
Communication tool:
-This level is crucial for collaboration between stakeholders, analysts and
developers to ensure everyone is on some page regarding the data model.
Entity-Relationship Diagrams (ERDs):
-Conceptual models are often represented visually using ERDs, which depict
entities as boxes and relationships as lines connecting them.
No technical details:
-The conceptual level does not involve specific database technologies or
implementation details like table structures, indexes, or data types.
Transformation to logical level:
-Once the conceptual level is agreed upon, it is then translated into a more detailed
“logical model” which add more specific attributes and constraints, while still
remaining technology-independent.
Characteristics;
-It represents all the entities, attributes, and relationship in the data model, and it
abstracts away from physical storage details.
-This level ensures data integrity and enforces constraints (like primary keys,
foreign keys)
-There is usually only one conceptual schema per database, which acts as a bridge
between the external and internal levels.
-Presents a simplified view of data, focusing on key business concepts and
relationships between them, rather than technical details like table structures (high-
level abstraction).
-Describes entities (like customers, products, orders) and their relationship (like
customer placing an order) using diagrams and notations to visualize the data
model (Entity-relationship focus).
-Represents data items that are easily understood by business users, aligning with
their perspective on the information needed (Business-oriented).
-Not tied to specific database technologies or storage structures, allowing
flexibility in choosing the best implementation later (independent of
implementation).
-The visual representation of the conceptual level, depicting entities, attributes, and
relationships within the data model (conceptual schema)
-Serves as a communication tool between database designers, system analysts, and
end-users to understand the requirements and relationships (Used for
communication).
Examples
. In the library database, the conceptual schema would define entities like Books,
Authors, and Borrowers, along with their attributes and relationships (e.g., Which
authors wrote which books).
Consider some key differences between conceptual and logical levels:
. Detail level; Conceptual level is more abstract and high-level, while the logical
level adds more detail by defining specific attributes and relationships, often
mapping to tables system.
. Implementation focus; Conceptual level is not concerned with physical
implementation details, whereas the logical level starts considering how the data
will be stored and accessed in a database system.
-is the lowest level of abstraction. It describes how the data is physically
stored in the database. Also known as the physical level, is the lowest level
of abstraction in a database management system (DBMS).
Consider some key points of the internal level (physical level) as follows;
Storage:
- The internal level describes how data is physically stored on a storage
device, such as a disk.
Allocation:
- The internal level is responsible for allocating space to the data.
Data independence:
- Physical data independence allows for modification to the storage device,
such as a disk.
Data structures:
- The physical level describes the complex structures and access methods
used by the data.
Physical schema:
- The physical schema of the internal level describes the details of how
data is stored, including files, indices, record layout, and file type.
Also, the physical level is the lowest level of data abstraction in a database.
Data independence is a crucial concept in database design and management,
and it refers to the ability to change the schema at one level without affecting
the next higher level. Physical data independence allows changes to the schema
at without affecting the conceptual schema or any external schemas.
Characteristics
-This level includes about data storage structures, file format, indexing methods,
and access paths.
-it is concerned with the optimization of storage, retrieval speed, and data
compression.
-The internal schema defines how data is physically organized, which can change
without affecting the conceptual or external levels.
Example: The internal level might specify that the Books table is stored in a B-tree
structure on disk for efficient searching and retrieval.
Advantages of the Three-level Architecture
a. Data independence
-Changes at one level (e.g., external) do not affect the other levels (e.g.,
external). This separation allows for easier data management and
modifications.
b. Improved security
-Users can be given access only to a specific view of the data, enhancing
data security.
d. Data integrity
-By defining primary and foreign keys, relationships between tables are
established, preventing inconsistencies and ensuring data accuracy.
e. Performance optimization
-A well-structured database design can significantly improve query speed
and efficiency by minimizing unnecessary data access.