Relational Database System With Necessary Example
Relational Database System With Necessary Example
Let's use a digital storefront as an example. Our database might have a table containing customer information, with columns
representing customer names or addresses, while each row contains data for one individual customer.
These tables can be linked or related using keys. Each row in a table is identified using a unique key, called a primary key. This primary
key can be added to another table, becoming a foreign key. The primary/foreign key relationship forms the basis of the way relational
databases work.
Returning to our example, if we have a table representing product orders, one of the columns might contain customer information.
Here, we can import a primary key that links to a row with the information for a specific customer.
➢ MySQL
➢ PostgreSQL
➢ MariaDB
➢ SQLite
2. Data hierarchy.
Data hierarchies refer to the organizational structure of data elements, where data is arranged in a hierarchical order or a tree-like
structure, with each level of the hierarchy representing a different level of abstraction or detail.
In a data hierarchy, the top level usually represents the most general or abstract data, and as we move down the hierarchy, we
encounter data that becomes increasingly specific or detailed. This hierarchical structure is often used to organize data in a way that
makes it easier to understand, manage, and analyze.
For example, in a retail business, the data hierarchy could start with the top level of the company’s overall sales data, which would
then be broken down into sales data for individual stores, then further broken down into sales data for each product category, and
finally, into individual product sales data. This hierarchical structure helps to provide a clear picture of the sales performance of the
company and its products at different levels of detail.
Overall, data hierarchies provide a structured approach to organizing and analyzing data, making it easier to navigate and interpret
complex datasets.
The Importance of Data Hierarchies:
1. Organization:
Data hierarchies provide a structured approach to organizing data, which makes it easier to manage and maintain. By organizing
data in a hierarchical structure, it becomes easier to locate and retrieve specific data elements, which can save time and increase
efficiency.
2. Analysis:
Hierarchical data structures provide a natural way to analyze data at different levels of granularity. By drilling down into the
hierarchy, analysts can gain a deeper understanding of the data and identify patterns or trends that may not be apparent at the
higher levels.
3. Decision-making:
Hierarchical data structures can be used to support decision-making by providing a clear and concise representation of the data.
By presenting data in a hierarchical structure, decision-makers can quickly identify key performance indicators, compare different
levels of data, and make more informed decisions.
4. Scalability:
Hierarchical data structures can be scaled to accommodate large and complex datasets. As data grows, additional levels can be
added to the hierarchy to accommodate new data elements, making it easier to manage and analyze data as it grows.
3. Three-Tier Architecture.
A 3-tier application architecture is a modular client-server architecture that consists of a presentation tier, an application tier and
a data tier. The data tier stores information, the application tier handles logic and the presentation tier is a graphical user interface
(GUI) that communicates with the other two tiers. The three tiers are logical, not physical, and may or may not run on the same
physical server.
The logical tiers of a 3-tier application architecture
Presentation tier: This tier, which is built with HTML5, cascading style
sheets (CSS) and JavaScript, is deployed to a computing device through
a web browser or a web-based application. The presentation tier
communicates with the other tiers through application program
interface (API) calls.
Application tier: The application tier, which may also be referred to as the logic tier, is written in a programming language such
as Java and contains the business logic that supports the application's core functions. The underlying application tier can either be
hosted on distributed servers in the cloud or on a dedicated in-house server, depending on how much processing power the
application requires.
Data tier: The data tier consists of a database and a program for managing read and write access to a database. This tier may also
be referred to as the storage tier and can be hosted on-premises or in the cloud. Popular database systems for managing read/write
access include MySQL, PostgreSQL, Microsoft SQL Server and MongoDB.
3-tier application programs may also be referred to as n-tier programs. In this context, the letter n stands for "a number of tiers."
5. Explain Treeview.
The TreeView control is used to display hierarchical representations of items similar to the ways the files and folders are displayed
in the left pane of the Windows Explorer. Each node may contain one or more child nodes.
BackColor
1
Gets or sets the background color for the control.
BackgroundImage
2
Gets or set the background image for the TreeView control.
BackgroundImageLayout
3
Gets or sets the layout of the background image for the TreeView control.
BorderStyle
4
Gets or sets the border style of the tree view control.
CheckBoxes
5
Gets or sets a value indicating whether check boxes are displayed next to the tree nodes in the tree view control.
DataBindings
6
Gets the data bindings for the control.
Font
7
Gets or sets the font of the text displayed by the control.
FontHeight
8
Gets or sets the height of the font of the control.
ForeColor
9
The current foreground color for this control, which is the color the control uses to draw its text.
ItemHeight
10
Gets or sets the height of each tree node in the tree view control.
Nodes
11
Gets the collection of tree nodes that are assigned to the tree view control.
PathSeparator
12
Gets or sets the delimiter string that the tree node path uses.
RightToLeftLayout
13
Gets or sets a value that indicates whether the TreeView should be laid out from right-to-left.
Scrollable
14
Gets or sets a value indicating whether the tree view control displays scroll bars when they are needed.
SelectedImageIndex
15
Gets or sets the image list index value of the image that is displayed when a tree node is selected.
SelectedImageKey
16
Gets or sets the key of the default image shown when a TreeNode is in a selected state.
SelectedNode
17
Gets or sets the tree node that is currently selected in the tree view control.
ShowLines
18
Gets or sets a value indicating whether lines are drawn between tree nodes in the tree view control.
ShowNodeToolTips
19
Gets or sets a value indicating ToolTips are shown when the mouse pointer hovers over a TreeNode.
ShowPlusMinus
20 Gets or sets a value indicating whether plus-sign (+) and minus-sign (-) buttons are displayed next to tree nodes that
contain child tree nodes.
ShowRootLines
21
Gets or sets a value indicating whether lines are drawn between the tree nodes that are at the root of the tree view.
Sorted
22
Gets or sets a value indicating whether the tree nodes in the tree view are sorted.
StateImageList
23
Gets or sets the image list that is used to indicate the state of the TreeView and its nodes.
Text
24
Gets or sets the text of the TreeView.
TopNode
25
Gets or sets the first fully-visible tree node in the tree view control.
TreeViewNodeSorter
26
Gets or sets the implementation of IComparer to perform a custom sort of the TreeView nodes.
VisibleCount
27
Gets the number of tree nodes that can be fully visible in the tree view control.
the For Each loop is a control structure used to iterate over elements in a collection, such as an array, a list, or any other type of
enumerable data structure.
Example:
Console.WriteLine(number)
Next
• Dim numbers As New List(Of Integer) From {1, 2, 3, 4, 5} creates a list of integers containing the numbers 1 through 5.
• For Each number As Integer In numbers starts the For Each loop, where number is a variable that will hold each element
of the numbers list in each iteration.
• Console.WriteLine(number) prints each number to the console.
• Next is used to indicate the end of the loop.
Labels:
The label control is used to display a text or a message to the user on the form. The label control is normally used along with other
controls. Common examples is wherein a label is added along with the textbox control. The label gives an indication to the user on
what is expected to fill up in the textbox. Let’s see how we can implement this with an example shown below. We will use a label
called ‘name.’ This will be used in conjunction with the textbox controls, which will be added in the later section.
Textbox:
A text box is used for allowing a user to enter some text on the Web form application. Let’s see how we can implement this with an
example shown below. We will add one textbox to the form in which the user can enter his name.
Radio button:
A Radio button is used to showcase a list of items out of which the user can choose one. Let’s see how we can implement this with
an example shown below. We will add a radio button for a male/female option.
To modify data in a database, you typically use the SQL UPDATE statement. This statement allows you to change the values of one or
more columns in one or more rows in a table based on specified conditions.
Syntax:
UPDATE table_name
WHERE condition;
• SET column1 = value1, column2 = value2, ...: Specifies the columns you want to update and their new values.
• WHERE condition: Optional. Specifies which rows to update based on a condition. If omitted, all rows in the table will be
updated.
Example:
Let's say you have a table called employees with columns id, name, salary, and department. You want to increase the salary of all
employees in the Marketing department by 10%. Here's how you would write the SQL query:
UPDATE employees
• This query updates the salary column for all rows in the employees table where the department is 'Marketing'.
• The SET salary = salary * 1.1 statement increases the salary of each matching row by 10%.
• The WHERE department = 'Marketing' clause specifies that only rows where the department column is equal to
'Marketing' will be updated.
9. Session tracking.
Session tracking is a mechanism used in web development to maintain stateful information about interactions between a user and a
web application across multiple requests. It's essential for applications that need to keep track of user-specific data, such as login
status, shopping cart contents, or preferences.
1. Cookies: One of the most common methods. A cookie is a small piece of data sent from a website and stored on the user's
computer by the user's web browser. Cookies can be used to store session IDs or other session-related data, allowing the
server to identify the user across requests.
2. URL Rewriting: In this method, a unique session identifier is appended to every URL on a website. When a user clicks a
link or submits a form, the session ID is included in the request, allowing the server to associate the request with a specific
session.
3. Hidden Form Fields: Session IDs can be stored in hidden form fields on HTML forms. When the form is submitted, the
session ID is sent to the server along with the other form data, allowing the server to identify the session.
4. Server-Side Sessions: In this method, session data is stored on the server, and the client is assigned a unique session ID
that is used to retrieve the session data on subsequent requests. Session data can be stored in memory, in a file, or in a
database, depending on the server configuration.