Essential Database Management Skills
Essential Database Management Skills
6.1 Introduction
This unit covers the competencies required to demonstrate database management skills. It
involves understanding database fundamentals, designing a database, using Structured
Query Language, understanding the design of object oriented databases, understanding
indexing and hashing and understanding database applications.
This learning outcome covers the definition of database, relational model and other
terminologies used in databases. It also explains the reasons for using databases, key concepts
in relational modelling, properties of tables and the MS SQL server interface. It also involves
comparing relational database management systems, demonstrating MS SQL server
installation and explaining MS SQL server database properties.
Database
A Database is a collection of related data organised in a way that data can be easily
accessed, managed and updated. Database can be software based or hardware based, with
one sole purpose, storing data
Table
A database table is composed of records and fields that hold data. Tables are also called
datasheets. Each table in a database holds data about a different, but related, subject.
Database engine
A database engine (or storage engine) is the underlying software component that a
database management system (DBMS) uses to create, read, update and delete (CRUD)
data from a database. ... The term "database engine" is frequently used interchangeably
with "database server" or "database management system".
Records
Data is stored in records. A record is composed of fields and contains all the data about one
particular person, company, or item in a database. In this database, a record contains the data
for one customer support incident report. Records appear as rows in the database table. A
record for Log ID 1201242 is highlighted in below.
Field
A field is part of a record and contains a single piece of data for the subject of the record. In
the database table illustrated in Figure below, each record contains four fields:
Log ID A number assigned to this customer support incident for
identification purposes
Operator The code for the customer support operator who handled
this incident
Resolved A check box to indicate whether the incident was resolved
Duration The time in seconds the operator spent on this incident
Fields appear as columns in a database table. Data from the Log ID field for five records is
highlighted in the Figure below.
Accurate
A database is pretty accurate as it has all sorts of build in constraints, checks etc. This
means that the information available in a database is guaranteed to be correct in most
cases.
Security of data
Databases have various methods to ensure security of data. There are user logins
required before accessing a database and various access specifiers. These allow only
authorised users to access the database.
Data integrity
This is ensured in databases by using various constraints for data. Data integrity in
databases makes sure that the data is accurate and consistent in a database.
Data sharing
The integration of all the data, for an organization, within a database system has many
advantages. First, it allows for data sharing among employees and others who have access
to the system. Second, it gives users the ability to generate more information from a given
amount of data than would be possible without the integration.
Data independence
Another advantage of a database management system is how it allows for data
independence. In other words, the system data descriptions or data describing data
(metadata) are separated from the application programs. This is possible because changes
to the data structure are handled by the database management system and are not embedded
in the program itself.
Relational model
The relational model represents the database as a collection of relations. A relation is
nothing but a table of values. In this model, data is organised in two-dimensional
tables and the relationship is maintained by storing a common field.
.
Weather
city state high low
Phoenix Arizona 105 90
Tucson Arizona 101 92
Flagstaff Arizona 88 69
San Diego California 77 60
New
Albuquerque 80 72
Mexico
Table Weather
Attributes/Columns
Each named column in a Table is an attribute. Attributes are the properties which define a
relation. e.g., Student_Rollno, NAME, etc.
Domain
A domain is the original sets of atomic values used to model data. By atomic value, we
mean that each value in the domain is indivisible as far as the relational model is
concerned. For example:
The domain of Marital Status has a set of possibilities: Married, Single, Divorced.
The domain of Shift has the set of all possible days: {Mon, Tue, Wed…}.
The domain of Salary is the set of all floating-point numbers greater than 0 and less
than 200,000.
The domain of First Name is the set of character strings that represents names of
people.
In summary, a domain is a set of acceptable values that a column is allowed to contain.
This is based on various properties and the data type for the column. We will discuss data
types in another chapter.
Tuples/Rows
A row—also called a tuple—represents a single, implicitly structured data item in a table.
Each row in a table represents a set of related data, and every row in the table has the same
structure.
Primary Key
A primary key is a field in a table which uniquely identifies each row/record in a
database table. Primary keys must contain unique values. A primary key column cannot
have NULL values. A table can have only one primary key, which may consist of single
or multiple fields.
.
Example:
Employee ID FirstName LastName
11 Andrew Johnson
22 Tom Wood
33 Alex Hale
Demonstration of a Primary Key
"Persons" table:
Persons table
PersonID LastNam FirstName Age
e
1 Hansen Ola 30
2 Svendson Tove 23
3 Pettersen Kari 20
"Orders" table:
Orders table
OrderI OrderNumbe PersonI
D r D
1 77895 3
2 44678 3
3 22456 2
4 24562 1
Notice that the "PersonID" column in the "Orders" table points to the "PersonID"
column in the "Persons" table.
The "PersonID" column in the "Persons" table is the PRIMARY KEY in the
"Persons" table.
The "PersonID" column in the "Orders" table is a FOREIGN KEY in the "Orders"
table.
The FOREIGN KEY constraint is used to prevent actions that would destroy links
between tables.
The FOREIGN KEY constraint also prevents invalid data from being inserted into the
foreign key column, because it has to be one of the values contained in the table it
points to.
Properties of a relation/table
Oracle DB is for large applications, particularly in the banking industry. Most of the world’s
top banks run Oracle applications because Oracle offers a powerful combination of
technology and comprehensive, pre-integrated business applications, including essential
functionality built specifically for banks.
The main disadvantage of using Oracle is that it is not free to use like its open source
competitors and can be quite expensive.
MS SQL server
Microsoft owns SQL Server. Like Oracle DB, the code is close sourced. Large enterprise
applications mostly use SQL Server.
Microsoft offers a free entry-level version called Express but can become very expensive as
you scale your application.
My SQL
MySQL is the most popular open source SQL database. It is typically used for web
application development, and often accessed using PHP.
The main advantages of MySQL are that it is easy to use, inexpensive, reliable (has been
around since 1995), and has a large community of developers who can help answer questions.
Some of the disadvantages are that it has been known to suffer from poor performance when
scaling, open source development has lagged since Oracle has taken control of MySQL, and
it does not include some advanced features that developers may be used to
.
Ms Access
Microsoft Access is a Database Management System offered by Microsoft. It uses the
Microsoft Jet Database Engine and comes as a part of the Microsoft Office suite of
application.
Microsoft Access offers the functionality of a database and the programming capabilities to
create easy to navigate screens (forms)
Installation of MS SQL server
Beginning with SQL Server 2016 (13.x), SQL Server is only available as a 64-bit application.
Here are important details about how to get SQL Server and how to install it.
Editions and features: Review the supported features for the different editions and versions
of SQL Server to determine which best suits your business needs.
SQL Server 2019 (15.x).
SQL Server 2017 (14.x).
SQL Server 2016 (13.x).
SQL Server 2014 (12.x)
Requirements: Review installation requirements, system configuration checks, and security
considerations in Planning a SQL Server Installation
1. The installer asks you to select the installation type, choose the Custom installation type
allows you to step through the SQL Server installation wizard and select the features that you
want to install.
2. Specify the folder for storing the installation files that the installer will download, then
click the Install button.
3. The installer starts downloading the install package for a while.
4. Once the download completes, open the folder that stores the install package and double-
click the [Link] file.
5. The following window displays; select the installation option on the left.
6. Click the first link to launch a wizard to install SQL Server 2017.
7. Specify the edition that you want to install, select Developer edition and click the Next
button.
8. Select the “I accept the license terms.” and click the Next button.
9. Check the “Use Microsoft Update to check for updates (recommended)” to get the security
and other important updates for the SQL Server and click the Next button.
10. The installation checks for the prerequisites before installation. If no error found, click the
Next button.
11. Select the features that you want to install. For now, you just need the Database Engine
Services, just check the checkbox and click the Next button to continue
12. Specify the name and install ID for the instance of the SQL Server and click the Next
button.
13. Specify the service account and collation configuration. Just use the default configuration
and click the Next button.
14. Specify the database engine security mode. First, choose Mixed Mode. Next, enter the
password for the SQL Server system administrator (sa) account. Then, re-enter the same
password to confirm it. After that, click the Add Current User button. Finally, click the Next
button.
First, download the SSMS from the Microsoft website via the following link:
Download SQL Server Management Studio
2. Wait for few minutes while the installer sets up the software.
Object Explorer (F8): Object Explorer is a tree view of all the database objects in a
server. This view includes the databases of the SQL Server Database Engine, SQL
Server Analysis Services, SQL Server Reporting Services, and SQL Server Integration
Services. Object Explorer includes information for all servers that are connected to it.
Query Window (Ctrl+N): After you select New Query, enter your Transact-SQL (T-
SQL) queries in this window. The results of your queries also appear here.
Properties (F4): You can see the Properties view when the Query Window is open.
The view displays basic properties of the query. For example, it shows the time that a
query started, the number of rows returned, and connection details.
Template Browser (Ctrl+Alt+T): Template Browser has various pre-built T-SQL
templates. You can use these templates to perform various functions, such as creating
or backing up a database.
Object Explorer Details (F7): This view is more granular than the view in Object
Explorer. You can use Object Explorer Details to manipulate multiple objects at the
same time. For example, in this window, you can select multiple databases, and then
either delete them or script them out simultaneously.
Change the environment layout
This section describes how to change the environment layout, such as how to move various
windows.
To move a window, press and hold the title, and then drag the window.
To pin or unpin a window, select the pushpin icon in the title bar:
Each window component has a drop-down menu that you can use to manipulate the
window in various ways:
When two or more query windows are open, the windows can be tabbed vertically or
horizontally so that both query windows are visible. To view tabbed windows, right-
click the title of the query, and then select the tabbed option that you want:
To restore the default environment layout, in the Window menu, select Reset Window
Layout:
Maximize Query Editor
You can maximize Query Editor to full-screen mode:
1. Click anywhere in the Query Editor window.
2. Press Shift+Alt+Enter to toggle between full-screen mode and regular mode.
This keyboard shortcut works with any document window.
Conclusion
At the end of this learning outcome, the learner should be able to define of database,
relational model and other terminologies used in databases. The learner should also be able to
explain the reasons for using databases, key concepts in relational modelling, properties of
tables and the MS SQL server interface. In addition, a learner should be able to compare
relational database management systems, demonstration of MS SQL server installation and
explanation of MS SQL server database properties should be one.
Further Reading
1. Elmasri, R., & Navathe, S. B. (2011). Database systems (Vol. 9). Boston, MA:
Pearson Education.
2. Hoffer, J. A., Ramesh, V., & Topi, H. (2011). Modern database management. Upper
Saddle River, NJ: Prentice Hall,.
3. Rankins, R., Jensen, P., & Bertucci, P. (2002). Microsoft SQL Server 2000
Unleashed. Sams Publishing.
4. Davidson, L. (2001). Professional SQL server 2000 database design. Birmingham,
UK: Wrox Press.
[Link] Self-Assessment
Written Assessment
Oral Assessment
Practical Assesssment
[Link] References
1. [Link]
2. [Link]
db_elements/db_elements2.htm
3. [Link] on 2nd March 2020)
6.3.3 Learning Outcome 2: Design a database
[Link] Learning Activities
Learning Outcome No.2: Design a Database
·
[Link] Information Sheet No 6/LO2: Design a Database
Introduction
This learning outcome covers explanation of the phases of database design,
illustration of entity modelling, entity model design and validation of the ER
model.
The conceptual database design phase starts with the formation of a conceptual data model
of the enterprise that is entirely independent of implementation details such as the target
DBMS, use of application programs, programming languages used, hardware platform,
performance issues, or any other physical deliberations.
The main aim of this model is to establish the entities, their attributes, and their
relationships. In this Data modeling level, there is hardly any detail available of the actual
Database structure.
The 3 basic tenants of Data Model are
Entity: A real-world thing
Attribute: Characteristics or properties of an entity
Relationship: Dependency or association between two entities
For example:
Customer and Product are two entities. Customer number and name are attributes of
the Customer entity
Product name and price are attributes of product entity
Sale is the relationship between the customer and product
The objective of logical database design methodology is to interpret the conceptual data
model into a logical data model and then authorize this model to check whether it is
structurally correct and able to support the required transactions or not.
Logical data models add further information to the conceptual model elements. It defines
the structure of the data elements and set the relationships between them.
The advantage of the Logical data model is to provide a foundation to form the base for the
Physical model. However, the modeling structure remains generic.
In this step of the database development life cycle, the main purpose is to translate the
conceptual data model created in conceptual methodology into a logical data model of the
data requirements of the enterprise. This objective can be achieved by following the
activities given below:
Obtain the relations for the logical data model
Authorize those relations using normalization
Validate those relations against user transactions
Check integrity control and its limitation
Evaluate the logical data model with user
Combine logical data models into the global model (This step is an optional one)
Check for future growth and development
The structure of the relational schema is authorized using normalization. It then makes sure
to ensure that the relations are capable of supporting the transactions given in the users'
requirements specification. You can then check those all-important integrity constraints
that are characterized by the logical data model. At this stage, the logical data model is
authorized by the users to ensure that they consider the model to be a true demonstration of
the data requirements for the enterprise.
This type of Data model also helps to visualize database structure. It helps to model database
columns keys, constraints, indexes, triggers, and other RDBMS features.
Example of Entities:
A university may have some departments. All these departments employ various lecturers
and offer several programs.
Some courses make up each program. Students register in a particular program and enroll in
various courses. A lecturer from the specific department takes each course, and each lecturer
teaches a various group of students.
b) Attributes
Attributes
c) Relationships
Relationship is nothing but an association among two or more entities. E.g., Tom works in
the Chemistry department.
Entities take part in relationships. We can often identify relationships with verbs or verb
phrases.
For example:
You are attending this lecture
I am giving the lecture
Just like entities, we can classify relationships according to relationship-types:
A student attends a lecture
A lecturer is giving a lecture.
Designing an Entity Model using UML (Unified Modelling Language)
There are three basic elements in an ER Diagram: entity, attribute, relationship. There are
more elements which are based on the main elements. They are weak entity, multi valued
attribute, derived attribute, weak relationship, and recursive relationship. Cardinality and
ordinality are two other notations used in ER diagrams to further define relationships
How to Draw ER Diagrams
Below points show how to go about creating an ER diagram.
1. Identify all the entities in the system. An entity should appear only once in a
particular diagram. Create rectangles for all entities and name them properly.
2. Identify relationships between entities. Connect them using a line and add a
diamond in the middle describing the relationship.
3. Add attributes for entities. Give meaningful attribute names so they can be
understood easily.
Sounds simple right? In a complex system, it can be a nightmare to identify relationships.
This is something you’ll perfect only with practice.
ER Diagram Best Practices
1. Provide a precise and appropriate name for each entity, attribute, and relationship in
the diagram. Terms that are simple and familiar always beats vague, technical-
sounding words. In naming entities, remember to use singular nouns. However,
adjectives may be used to distinguish entities belonging to the same class (part-time
employee and full-time employee, for example). Meanwhile attribute names must be
meaningful, unique, system-independent, and easily understandable.
2. Remove vague, redundant or unnecessary relationships between entities.
3. Never connect a relationship to another relationship.
4. Make effective use of colors. You can use colors to classify similar entities or to
highlight key areas in your diagrams.
Worked Examples in ER Modelling
ER diagram of Branch Has Staff relationship
Figure 18:Entities associated through two distinct relationships with role names
Figure 19:ER diagram of Staff and Branch entities and their attributes
Normalization
Database normalization is a database schema design technique, by which an existing
schema is modified to minimize redundancy and dependency of data.
b) Update Anomaly
In this case we have the same information in several rows. For instance if the office number
changes, then there are multiple updates that need to be made. If we don’t update all rows,
then inconsistencies appear.
c) Deletion Anomaly
Deletion of a row causes removal of more than one set of facts. For instance, if John Hunt
retires, then deleting that row cause us to lose information about the New York office.
Here you see Movies Rented column has multiple values. Now let's move into 1st
Normal Forms:
1NF (First Normal Form) Rules
Each table cell should contain a single value.
Each record needs to be unique.
The above table in 1NF-
1NF Example
We have divided our 1NF table into two tables viz. Table 1 and Table2. Table 1 contains
member information. Table 2 contains information on movies rented.
We have introduced a new column called Membership_id which is the primary key for table
1. Records can be uniquely identified in Table 1 using membership id
Database - Foreign Key
In Table 2, Membership ID is the Foreign Key
We have again divided our tables and created a new table which stores Salutations.
There are no transitive functional dependencies, and hence our table is in 3NF
In Table 3 Salutation ID is primary key, and in Table 1 Salutation ID is foreign to primary
key in Table 3
Now our little example is at a level that cannot further be decomposed to attain higher forms
of normalization. In fact, it is already in higher normalization forms. Separate efforts for
moving into next levels of normalizing data are normally needed in complex databases.
However, we will be discussing next levels of normalizations in brief in the following.
CRUD is an acronym that refers to the following actions on an object (typically a data
entity):
Create - to create and store new data
Read - to retrieve and read data
Update - to change or modify then store the data.
Delete - to delete or remove the data
A CRUD matrix is a very useful way to capture and display activities and permissions
within a system. It is very valuable to combine a CRUD Matrix with the analysis of user
processes within the system, especially in the context of the actors and roles involved to
complete the picture. The analysis helps to identify the usage of entities and associated
GUIs. The information that is used heavily, and may therefore be a performance
bottleneck, is also easily identified.
The simple example below illustrates how to capture this information. In this case what is
shown is what access or usage that a role has with a particular protected object (i.e., data
entity, or activity, etc.).
Crud Matrix A
In the following example, another way to capture this information, the protected objects are
list across the top, with permissions/usage define in each cell.
Object
Order Invoice Customer Employee Product
Role
Sales VP crud crud crud crud crud
Sales Manager crud crud ru r r
Sales Rep crud r ru r R
Stock Manager - - - r Ru
Note that "crude" appears, which is create; read; update; delete; and execute. Execute is
added here, indicating that a "Sale Manager" role can execute (fulfill) an Order.
Conclusion
At the end of this learning outcome, the leaner should be able to explain of the phases of
database design, illustrate entity modelling, entity model design and validate other ER
model.
Further Reading
1. Batini, C., Ceri, S., & Navathe, S. B. (1992). Conceptual database design: an Entity-
relationship approach (Vol. 116). Redwood City, CA: Benjamin/Cummings.
2. Elmasri, R., & Navathe, S. B. (2011). Database systems (Vol. 9). Boston, MA:
Pearson Education.
3. Hoffer, J. A., Ramesh, V., & Topi, H. (2011). Modern database management. Upper
Saddle River, NJ: Prentice Hall,.
4. Rankins, R., Jensen, P., & Bertucci, P. (2002). Microsoft SQL Server 2000 Unleashed.
Sams Publishing.
[Link] Self-Assessment
Written Assessment
6. Entity is a _________
a) Object of relation
b) Present working model
c) Thing in real world
d) Model of relation
9. Consider a directed line (->) from the relationship set advisor to both entity sets
instructor and student. This indicates _________ cardinality
a) One to many
b) One to one
c) Many to many
d) Many to one
10. We indicate roles in E-R diagrams by labeling the lines that connect ___________ to
__________
a) Diamond , diamond
b) Rectangle, diamond
c) Rectangle, rectangle
d) Diamond, rectangle
Oral Assessment
1. What is the difference between Primary and Unique Key
2. Explain any 3 symbols used in ER Modelling.
Practical Assessment
1. Model the relationship between Bank, Employees and Clients
2. Use ER diagram to describe a Weak Entity set
[Link] Tools, Equipment, Supplies and Materials
Microsoft Office with MS Visio Modelling tool
MS SQL server software
Computers
Instruction material
Stationery
Internet
[Link] References
Introduction
This learning outcome covers explaining SQL and data definition, creating tables using
CREATE TABLE constraints, using the ALTER TABLE AND DROP TABLE statements,
demonstrating data manipulation query statements, explaining joins and demonstrating
types of joins and creating and querying a database from validated ER model.
The columns can range from one to a standard 1024 number of columns though other
management tools could allow for more.
The data types do not differ much with regular data types used in programming languages,
e.g. integer, varchar, date, datetime, timestamp, float, lately json among others.
NOT NULL – this ensures that a column cannot have a NULL value.
UNIQUE - Ensures that all values in a column are different.
PRIMARY KEY - A combination of a NOT NULL and UNIQUE. Uniquely identifies
each row in a table.
FOREIGN KEY - Uniquely identifies a row/record in another table.
CHECK - Ensures that all values in a column satisfy a specific condition.
DEFAULT - Sets a default value for a column when no value is specified.
INDEX - Used to create and retrieve data from the database very quickly.
For example, consider the table student_details. To select the first name of all the students the
query would be like:
You can also retrieve data from more than one column. For example, to select first
name and last name of all the students.
NOTE: In a SQL SELECT statement only SELECT and FROM statements are mandatory.
Other clauses like WHERE, ORDER BY, GROUP BY, HAVING are optional.
For example: If we want to display the first and last name of an employee combined
together, the SQL Select Statement would be like
Output:
emp_name
Rahul Sharma
Anjali
Bhagwat
Stephen
Fleming
Shekar
Gowda
Priya Chandra
SQL ALIAS
SQL Aliases are defined for columns and tables. Basically aliases is created to make the
column selected more readable.
For Example: To select the first name of all the students, the query would be like:
or
In the above query, alias 's' is defined for the table student_details and the column first_name
is selected from the table.
The condition you provide in the WHERE clause filters the rows retrieved from the table and
gives you only those rows which you expected to see. WHERE clause can be used along with
SELECT, DELETE, UPDATE statements.
Comparison Operators and Logical Operators are used in WHERE Clause (Discussed
later)
ag salar
id name dept location
e y
10 Rames 2500 Bangalor
Electrical 24
0 h 0 e
10 Hrithi Electroni 3500 Bangalor
28
1 k cs 0 e
10 Harsh Aeronauti 3500
28 Mysore
2 a cs 0
10 Soum Electroni 2000 Bangalor
22
3 ya cs 0 e
10 3000 Mangalo
Priya InfoTech 25
4 0 re
If you want to display employee name, current salary, and a 20% increase in the
salary for only those employees where the percentage increase in salary is greater than
30000, the SELECT statement can be written as shown below
Output:
Name salary new_salary
Hrithik 35000 42000
Harsha 35000 42000
Priya 30000 36000
SQL OPERATORS
There are two types of Operators, namely Comparison Operators and Logical Operators.
These operators are used mainly in the WHERE clause, HAVING clause to filter the data to
be selected.
Comparison Operators:
Comparison operators are used to compare the column data with specific values in a
condition.
Comparison Operators are also used along with the SELECT statement to filter data based on
specific conditions.
Logical Operators:
There are three Logical Operators namely, AND, OR, and NOT. These operators compare
two conditions at a time to determine whether a row can be selected for the output. When
retrieving data using a SELECT statement, you can use logical operators in the WHERE
clause, which allows you to combine more than one condition.
Logical
Description
Operators
For the row to be selected
OR at least one of the
conditions must be true.
For a row to be selected
AND all the specified
conditions must be true.
For a row to be selected
NOT the specified condition
must be false.
For example: if you want to find the names of students who are studying either Maths or
Science, the query would be like,
For Example: To find the names of the students between the age 10 to 15 years, the query
would be like:
SELECT first_name, last_name, age
FROM student_details
WHERE age >= 10 AND age <= 15;
The following table describes how logical "AND" operator selects a row.
Column1 Column2 Row
Satisfied? Satisfied? Selected
YES YES YES
YES NO NO
NO YES NO
NO NO NO
If you want to find rows that do not satisfy a condition, you can use the logical operator,
NOT. NOT results in the reverse of a condition. That is, if a condition is satisfied, then the
row is not returned.
For example: If you want to find out the names of the students who do not play football, the
query would be like:
The following table describes how logical "NOT" operator selects a row.
NOT
Column1 Row
Column1
Satisfied? Selected
Satisfied?
YES NO NO
NO YES YES
For example: If you want to select the names of the students whose’ age is between 10 and
15 years, or those who do not play football, the SELECT statement would be
SELECT first_name, last_name, age, games
FROM student_details
WHERE age >= 10 AND age <= 15
OR NOT games = 'Football'
NOTE:The order in which you phrase the condition is important, if the order changes you
are likely to get a different result.
For example: To select all the students whose name begins with 'S'
The above select statement searches for all the rows where the first letter of the column
first_name is 'S' and rest of the letters in the name can be any character.
There is another wildcard character you can use with LIKE operator. It is the underscore
character, ' _ ' . In a search string, the underscore signifies a single character.
For example: to display all the names with 'a' second character,
NOTE: Each underscore act as a placeholder for only one character. So you can use more
than one underscore. Eg: ' __i% '-this has two underscores towards the left, 'S__j%' - this has
two underscores between character 'S' and 'i'.
SQL IN Operator:
The IN operator is used when you want to compare a column with more than one value. It is
similar to an OR condition.
For example: If you want to find the names of students who are studying either Maths or
Science, the query would be like,
For Example: If you want to find the names of students who do not participate in any games,
the query would be as given below
There would be no output as we have every student participate in a game in the table
student_details, else the names of the students who do not participate in any games would be
displayed.
SQL ORDER BY
The ORDER BY clause is used in a SELECT statement to sort results either in ascending or
descending order. Oracle sorts query results in ascending order by default.
ag salar
id name dept location
e y
10 Rames Electrical 24 2500 Bangalor
0 h 0 e
10 Hrithi Electroni 3500 Bangalor
28
1 k cs 0 e
10 Harsh Aeronauti 3500
28 Mysore
2 a cs 0
10 Soum Electroni 2000 Bangalor
22
3 ya cs 0 e
10 3000 Mangalo
Priya InfoTech 25
4 0 re
For Example: If you want to sort the employee table by salary of the employee, the sql query
would be.
The query first sorts the result according to name and then displays it.
You can also use more than one column in the ORDER BY clause.
If you want to sort the employee table by the name and salary, the query would be like,
SELECT name, salary FROM employee ORDER BY name, salary;
NOTE:The columns specified in ORDER BY clause should be one of the columns selected
in the SELECT column list.
You can represent the columns in the ORDER BY clause by specifying the position of a
column in the SELECT list, instead of writing the column name.
The above query can also be written as given below,
SELECT name, salary FROM employee ORDER BY 1, 2;
By default, the ORDER BY Clause sorts data in ascending order. If you want to sort the data
in descending order, you must explicitly specify it as shown below.
The above query sorts only the column 'salary' in descending order and the column 'name' by
ascending order.
If you want to select both name and salary in descending order, the query would be as given
below.
NOTE: Aliases defined in the SELECT Statement can be used in ORDER BY Clause.
For Example: If you want the number of employees in a particular department, the query
would be:
SELECT COUNT (*) FROM employee
WHERE dept = 'Electronics';
The output would be '2' rows.
If you want the total number of employees in all the department, the query would take the
form:
SELECT COUNT (*) FROM employee;
For Example: If you want to select all distinct department names from employee table, the
query would be:
To get the count of employees with unique name, the query would be:
SELECT COUNT (DISTINCT name) FROM employee;
SQL MAX(): This function is used to get the maximum value from a column.
To get the maximum salary drawn by an employee, the query would be:
SQL MIN(): This function is used to get the minimum value from a column.
To get the minimum salary drawn by an employee, The query would be:
SQL AVG(): This function is used to get the average value of a numeric column.
To get the average salary, the query would be
SQL SUM(): This function is used to get the sum of a numeric column
To get the total salary given out to the employees,
For Example: If you want to know the total amount of salary spent on each department,
the query would be:
dept salary
Electrical 25000
Electronics 55000
Aeronautics 35000
InfoTech 30000
For Example: If you want to select the department that has total salary paid for its
employees more than 25000, the sql query would be like;
Finally, any conditions on the group functions in the HAVING clause are applied to the
grouped rows before the final output is displayed.
For Example: To add a column "experience" to the employee table, the query
would be like
For Example: To drop the column "location" from the employee table, the
query would be like
For Example: To modify the column salary in the employee table, the query would
be like
For Example: To drop the table employee, the query would be like
DROP TABLE employee;
While inserting a row, if you are adding value for all the columns of the table you need not
specify the column(s) name in the sql query. But you need to make sure the order of the
values is in the same order as the columns in the table.
For Example: If you want to insert a row to the employee table, the query would be like,
NOTE: When adding a row, only the characters o te values r da should be enclosed with
single quotes.
If you are inserting data to all the columns, the column names can be omitted. The above
insert statement can also be written as,
For Example: To insert a row into the employee table from a temporary table, the sql insert
query would be like,
If you are inserting data to all the columns, the above insert statement can also be written as,
NOTE: We have assumed the temp_employee table has columns emp_id, emp_name, dept,
age, salary, location in the above given order and the same datatype.
IMPORTANT NOTE:
1) When adding a new row, you should ensure the datatype of the value and the column
matches
2) You follow the integrity constraints, if any, defined for the table.
UPDATE table_name
SET column_name1 = value1,
column_name2 = value2, ...
[WHERE condition]
table_name - the table name which has to be updated.
column_name1, column_name2.. - the columns that gets changed.
value1, value2... - are the new values.
NOTE: In the Update statement, WHERE clause identifies the rows that get affected. If you
do not include the WHERE clause, column values for all the rows get affected.
For Example: To update the location of an employee, the sql update query would be like,
UPDATE employee
SET location ='Mysore'
WHERE id = 101;
To change the salaries of all the employees, the query would be,
UPDATE employee
SET salary = salary + (salary * 0.2);
NOTE:The WHERE clause in the sql delete command is optional and it identifies the rows
in the column that gets deleted. If you do not include the WHERE clause all the rows in the
table is deleted, so be careful while writing a DELETE query without WHERE clause.
For Example: To delete an employee with id 100 from the employee table, the sql delete
query would be like,
To delete all the rows from the employee table, the query would be like,
For Example: To delete all the rows from employee table, the query would be like,
TRUNCATE TABLE employee;
DELETE Statement: This command deletes only the rows from the table based on the
condition given in the where clause or deletes all the rows from the table if no condition is
specified. But it does not free the space containing the table.
TRUNCATE statement: This command is used to delete all the rows from the table and free
the space containing the table.
Sql joins
SQL Joins are used to relate information in different tables. A Join condition is a part of the
SQL query that retrieves rows from two or more tables. A SQL Join condition is used in
the SQL WHERE Clause of select, update, delete statements.
If an SQL join condition is omitted or if it is invalid the join operation will result in a
Cartesian product.
The Cartesian product returns a number of rows equal to the product of all rows in all the
tables being joined. For example, if the first table has 20 rows and the second table has 10
rows, the result will be 20 * 10, or 200 rows. This query takes a long time to execute.
Lets use the below two tables to explain the sql join conditions.
database table "product";
produ product_ supplier_ unit_p
ct_id name name rice
100 Camera Nikon 300
Televisio
101 Onida 100
n
Refrigera
102 Vediocon 150
tor
103 Ipod Apple 75
104 Mobile Nokia 50
SQL Joins can be classified into Equi join and Non Equi join.
For example: You can get the information about a customer who purchased a product and
the quantity of product.
For example: If you want to display the product information for each order the query will be
as given below.
Since you are retrieving the data from two tables, you need to identify the common column
between these two tables, which is the product_id.
The columns must be referenced by the table name in the join condition, because product_id
is a column in both the tables and needs a way to be identified. This avoids ambiguity in
using the columns in the SQL SELECT statement.
The number of join conditions is (n-1), if there are more than two tables joined in a query
where 'n' is the number of tables involved. The rule must be true to avoid Cartesian product.
We can also use aliases to reference the column name, then the above query would be like,
The syntax differs for different RDBMS implementation. Few of them represent the join
conditions as "SQL left outer join", "SQL right outer join".
If you want to display all the product data along with order items data, with null values
displayed for order items if a product has no order item, the SQL query for outer join would
be as shown below:
NOTE:If the (+) operator is used in the left side of the join condition it is equivalent to left
outer join. If used on the right side of the join condition it is equivalent to right outer join.
Conclusion
At the end of this learning outcome, the learner should be able to eexplain SQL and data
definition, create tables using CREATE TABLE constraints, use the ALTER TABLE AND
DROP TABLE statements, demonstrate data manipulation query statements, explain and
demonstrating types of joins, create and query a database from validated ER model.
Further Reading
Davidson, L. (2001). Professional SQL server 2000 database design. Birmingham, UK:
Wrox Press.
9. Which key word is used with update command to change the value?
a. Alter
b. Set
c Change
d. Add
Oral Assessment
1. What are the risks involved in using the DROP table command
2. What is the role of a join?
Practical assessment
Consider the following table to answer the questions that follow:
Customer
Customer_I Name Address Town Age
D
503998 Charles 1423 Nakuru 43
504321 Mary 564 Nairobi 23
502342 Judy 4234 Mombasa 12
502321 Maina 7765 Kisumu 23
Required
Write the SQL statement which could be used to
(a) Create the table above
(b) Display a list of customer who are below 30yrs and come from Nairobi
(c) Add a new column called Physical Location to the Table
(d) Delete all the rows whose customers are above 40 yrs of age
e) Update the address of whose Customer_ID is 504321 to 68232
[Link] References
1) Davidson, L. (2001). Professional SQL server 2000 database design. Birmingham,
UK: Wrox Press.
2) [Link]
3) [Link]
explained-in-simple-english/(Retrieved on 2nd March 2020
6.3.5 Learning Outcome 4: Understand design of object oriented databases
[Link] Learning Activities
Learning Outcome No. 4: Understand design of object oriented databases
·
[Link] Information Sheet No 6/LO4: Understand design of object oriented databases
Introduction
This learning outcome covers explaning object oriented databases and their concepts,
implementing object oriented concepts and creating views and triggers.
Object oriented database- A database management system in which data is stored in the
form of objects which are instances of classes.
Class-A collection of objects with the same or similar attributes and behavior.
Inheritance-Creation of a new object from an existing object in such a way that a new
object inherits all characteristics of an existing object.
Objects are created using the CREATE [OR REPLACE] TYPE statement. Following is an
example to create a simple address object consisting of few attributes –
Type created.
Let's create one more object customer where we will wrap attributes and methods together
to have object-oriented feeling –
Instantiating an Object
Defining an object type provides a blueprint for the object. To use this object, you need to
create instances of this object. You can access the attributes and methods of the object using
the instance name and the access operator (.) as follows −
DECLARE
residence address;
BEGIN
residence := address('103A', '[Link]', 'Jaipur', 'Rajasthan','201301');
dbms_output.put_line('House No: '|| residence.house_no);
dbms_output.put_line('Street: '|| [Link]);
dbms_output.put_line('City: '|| [Link]);
dbms_output.put_line('State: '|| [Link]);
dbms_output.put_line('Pincode: '|| [Link]);
END;
/
When the above code is executed at the SQL prompt, it produces the following result −
Member Methods
Member methods are used for manipulating the attributes of the object. You provide the
declaration of a member method while declaring the object type. The object body defines the
code for the member methods. The object body is created using the CREATE TYPE BODY
statement.
Constructors are functions that return a new object as its value. Every object has a system
defined constructor method. The name of the constructor is same as the object type. For
example –
The comparison methods are used for comparing objects. There are two ways to compare
objects
Map method
The Map method is a function implemented in such a way that its value depends upon the
value of the attributes. For example, for a customer object, if the customer code is same for
two customers, both customers could be the same. So the relationship between these two
objects would depend upon the value of code.
Order method
The Order method implements some internal logic for comparing two objects. For
example, for a rectangle object, a rectangle is bigger than another rectangle if both its sides
are bigger.
When the above code is executed at the SQL prompt, it produces the following result −
Type created.
Length: 20
Width: 10
Material: Wood
Length: 50
Width: 30
Material: Steel
create or replace
view view_name
as
select column_name1, column_name2,...
from table_name
where condition;
For example
A table of names and addresses is created of students whose student ID value is less than 4.
Trigger-These are stored programs which are automatically executed whenever a special
event occurs in the data
The following table shows the content of the INSERTED and DELETED tables before and after
each event:
DML event INSERTED table holds DELETED table holds
INSERT rows to be inserted empty
UPDATE new rows modified by the update existing rows modified by the update
DELETE Empty rows to be deleted
We will use the following [Link] table from the sample database for the
demonstration.
Create a table for logging the changes
The following statement creates a table named production.product_audits to record
information when an INSERT or DELETE event occurs against
the [Link] table:
Then, you list the one or more events which will call the trigger in the AFTER clause:
AFTER INSERT, DELETE
After that, inside the body of the trigger, you set the SET NOCOUNT to ON to suppress the
number of rows affected messages from being returned whenever the trigger is fired.
SET NOCOUNT ON;
The trigger will insert a row into the production.product_audits table whenever a row is
inserted into or deleted from the [Link] table. The data for insert is fed from
the INSERTED and DELETED tables via the UNION ALL operator:INSERT INTO
production.product_audits
(
product_id,
product_name,
brand_id,
category_id,
model_year,
list_price,
updated_at,
operation
)
SELECT
i.product_id,
product_name,
brand_id,
category_id,
model_year,
i.list_price,
GETDATE(),
'INS'
FROM
inserted AS i
UNION ALL
SELECT
d.product_id,
product_name,
brand_id,
category_id,
model_year,
d.list_price,
getdate(),
'DEL'
FROM
deleted AS d;
Finally, you execute the whole statement to create the trigger. Once the trigger is created, you
can find it under the triggers folder of the table as shown in the following picture:
Testing the trigger
The following statement inserts a new row into the [Link] table:
SELECT
*
FROM
production.product_audits;
Here is the output:
The following statement deletes a row from the [Link] table:
DELETE FROM
[Link]
WHERE
product_id = 322;
As expected, the trigger was fired and inserted the deleted row into
the production.product_audits table:
SELECT
*
FROM
production.product_audits;
The following picture shows the output:
Conclusion
At the end of this learning outcome, the learner should be able to explain object oriented
databases and their concepts, implement object oriented concepts and create views and
triggers.
Further Reading
Davidson, L. (2001). Professional SQL server 2000 database design. Birmingham, UK:
[Link] Self-Assessment
Written Assessment
1.A __________ is a special kind of a stored procedure that executes in response to certain
actions on the table like insertion, deletion or updating of data.
a. Procedures
B. B. Triggers
c. Functions
d. None of the mentioned
2. The CREATE TRIGGER statement is used to create the trigger. THE _____ clause
specifies the table name on which the trigger is to be attached. The ______ specifies that
this is an AFTER-INSERT trigger.
a. for insert, on
b. On, for insert
c. For, insert
d. Both a and c
3. What is the purpose of a view?
4. What command do you use to create a view?
5. How is a view different from a normal table?
Oral Assessment
Explain object oriented concepts that can be used in object oriented databases.
Practical Assessment
Create a database with an Employee table that has the following schema, then demonstrate
how insertion and deletion of records using a trigger.
·
[Link] Information Sheet No 6/LO5: Understand indexing and hashing
Introduction
This learning outcome covers explaining, demonstrating and implementing indexing and
hashing in a database.
Indexing
Indexes are special lookup tables that the database search engine can use to speed up data
retrieval. Simply put, an index is a pointer to data in a table. An index in a database is very
similar to an index in the back of a book.
For example, if you want to reference all pages in a book that discusses a certain topic, you
first refer to the index, which lists all the topics alphabetically and are then referred to one or
more specific page numbers.
An index helps to speed up SELECT queries and WHERE clauses, but it slows down data
input, with the UPDATE and the INSERT statements. Indexes can be created or dropped
with no effect on the data.
Creating an index involves the CREATE INDEX statement, which allows you to name the
index, to specify the table and which column or columns to index, and to indicate whether
the index is in an ascending or descending order.
Indexes can also be unique, like the UNIQUE constraint, in that the index prevents
duplicate entries in the column or combination of columns on which there is an index.
Types of indexing
Primary Indexing- Data is sorted according to the search key the primary key of the database
table is used to create the index .There is a one-to-one relationship between the entries in the
index table and the records in the main table making quick and efficient.
Hashing
This is a technique used to directly search the location of desired data on the disk without
using index structure. Data is stored in the form of data blocks whose address is generated
by applying a hash function in the memory location where these records are stored known
as a data block or data bucket.
Hash Function-It that maps all the set of search keys to actual record address. It can be a single
mathematical function
Types of Hashing
1. Static Hashing-when a search-key value is provided, the hash function always computes
the same address.
2. Dynamic Hashing-Static hashing does not expand or shrink as the size of the database
grows or shrinks. Dynamic hashing provides a mechanism in which data buckets are
added and removed dynamically and on-demand.
Figure 20:Hashing in a database
Note: Updating a table with indexes takes more time than updating a table without (because
the indexes also need an update). So, only create indexes on columns that will be frequently
searched against.
Further Reading
1. [Link]
2. [Link]
3. [Link]
[Link] Self-Assessment
Written Assessment
1. What is the purpose of index in sql server
A. To enhance the query performance
B. To provide an index to a record
C. To perform fast searches
D. All of the mentioned
2. An indexing operation
A. sorts a file using a single key
B. sorts file using two keys
C. establishes an index for a file
D. both (b) and (c)
3. The index consists of
A. a list of keys
B. pointers to the master list
C. both (a) and (b)
D. All of the above
4. The hashing technique which allocates fixed number of buckets is classified as
A. dynamic hashing
B. Static hashing
C. external hashing
D. internal hashing
5. The index which has an entry for some of the key value is classified as
A. linear index
B. dense index
C. Sparse index
D. cluster index
6. What is the name given to indexing based on assorted order?
A. Sequenced indices
B. hashing indices
C ordered indices
D. Structured indices
9. A harsh function must meet______criteria
A. 2
B. 3
C. 4
D. none of the above
Oral Assessment
When should use of indexes be avoided?
Practical Assessment
Create a database with an Employee table that has the following schema, then demonstrate
how a single column index can be created for the table.
[Link] References
1. [Link]
2. [Link]
6.3.7 Learning Outcome 6: Understand Database applications
[Link] Learning Activities
Learning Outcome No.6: Understand Database applications
6.1 Decision support systems are explained. Activities may be carried out in
6.2 Data mining is explained groups or as individual
6.3 Distributed databases are demonstrated
6.4 Data warehousing is illustrated
6.5 Spatial and geographical databases are explained ·
6.6 Multi-media databases are illustrated
6.7 Mobility and personal databases are explained.
6.8 Data warehouses are designed and implemented from
a given set of requirements.
·
[Link] Information Sheet No 6/LO6: Understand Database applications
Introduction
This learning outcome covers explaining decision support systems, data mining, mobility
and personal databases, spatial and geographical databases, demonstrating distributed
databases, illustrating multi-media databases, illustrating, designing and implementing a
data warehouse.
Database Mining-In organizations data is stored in databases. Data mining is the process
of automatically searching large databases to discover anomalies, patterns and correlations
within large data sets to predict outcomes. Data mining is used in sectors like
Marketing -To explore databases and to improve market segmentation by analysing the
relationships between parameters such as customer age, gender, tastes, etc. The trends can
predict which users are likely to unsubscribe from a service, what interests them based on
their searches, to achieve a higher response rate.
Retail- Supermarkets, for example, use joint purchasing patterns to identify product
associations and decide how to place them in the aisles and on the shelves.
Medicine-Data mining enables more accurate diagnostics. Having all of the patient's
information, such as medical records, physical examinations, and treatment patterns, allows
more effective treatments to be prescribed. It also enables more effective, efficient and
cost-effective management of health resources by identifying risks, predicting illnesses in
certain segments of the population or forecasting the length of hospital admission
Consider a banking system consisting of four branches in four different cities. Each branch
has its own computer, with a database of all the accounts maintained at that branch. Each
installation is a site. There also exists one single site that maintains information about all
the branches of the bank.
The site containing information about all the branches of the bank maintains the relation
branch
Branch schema is as follows: ( branch_name, branch-city, assets).
- Replication: The system maintains several identical replicas (copies) of the table, and stores
each replica at a different site. The alternation to replication is to store only one copy of
relation t.
- Fragmentation. The system partitions the table into several fragments, and stores each
fragment at a different site.
The two can be combined. A table can be partitioned into several fragments and there may be
several replicas of each fragment.
Data Replication
If table t replicated, a copy of the table is stored in two or more sites. In the most extreme case, we
have full replication, in which a copy is stored in every site in the system.
Advantages of replication
- Availability: If one of the sites containing table t fails, then the table can be found in another
site. Thus the system can continue to process queries involving the table t, despite the failure
of one site.
- Increased parallelism: Several sites can process queries involving the table t in parallel. The
more replicas of r there are, the greater the chance that the needed data will be found in the
site where the transaction is executing. Hence data replication minimizes movement of data
between sites.
Disadvantages of replication
- Increased overhead on update: The system must ensure that all replicas of a table t, are
consistent, otherwise erroneous computations may result. Thus whenever t is updated, the
update must be communicated to all sites containing replicas. The result is increased
overhead. For example, in a banking system, where account information is replicated in
various sites; it is necessary to ensure that the balance in a particular account agrees in all
sites.
Data Fragmentation
If table t is fragmented, t is divided into a number of fragments t1, t2, t3,…., tn. These fragments
contain sufficient information to allow reconstruction of the original t.
Goals of fragmentation
Fragmentation aims to improve:
- Reliability
- Performance
- Balanced storage capacity and costs
- Communication costs
- Security
Types of fragmentation
There are two different schemes for fragmenting a table: Horizontal fragmentation and Vertical
fragmentation.
Horizontal fragmentation
- It splits the table by assigning each row to one or more fragments.
Vertical Fragmentation
- Splits the table by assigning each column to one or more fragments.
Example
Horizontal fragmentation of PROJ table
PROJ1: projects with budgets less than 200, 000
PROJ2: projects with budgets greater than or equal to 200, 000
Homogeneous DDBMS
- All sites use same DBMS product
- All sites are aware of one another and agree to co-operate in processing
- Sites surrender a portion of their autonomy in terms of their right to change schemas or
DBMS software.
- The DBMS software must also co-operate with other sites in exchanging information about
transactions to make transaction processing across multiple sites.
- It is much easier to design and manage
- The approach provides incremental growth and allows increased performance
Heterogeneous DDBMS
- Sites may run different DBMS products, with possibly different underlying data models
- Sites may not be aware of one another and may provide only limited facilities for co-
operation in transaction processing. This occurs when sites have implemented their own
databases first, and integration is considered later.
- Translations are required to allow for different hardware and/or different DBMS products
- Differences in schema often a major problem for query processing, while divergence in
software becomes a hindrance for processing transactions that access multiple sites.
- Autonomy
Each site is able to maintain a degree of control over data that are stored
locally.
- Availability
If one site fails in a distributed system, the remaining sites may be able to
continue operating. This is because data items are replicated in several sites.
o Parallelism in execution
Transparency: Hiding database implementation details from the users such as where the data is
physically located or how the data is accessed at the specific local site.
Data Warehousing
This is a system of pulling together data from many different sources within an
organization for reporting and analysis to make viable decisions
Features of data warehouse
1. Subject oriented-It provides information around a subject rather than the
organization's ongoing operations e.g. product, customers, suppliers, sales, revenue
2. Integrated –Data from different heterogeneous sources is stored in a common and
universally accepted manner
3. Time-Variant –Data collected in a data warehouse is identified with a particular time
period e. g. Weekly, Monthly, Annually
4. Non-volatile-Data residing in a data warehouse is permanent, meaning that data is not
erased or deleted when new data is inserted.
Multimedia databases - A database that stores data in the form of text, images, videos,
audio animations.
Star Schema
Each dimension in a star schema is represented with only one-dimension table.
This dimension table contains the set of attributes.
The following diagram shows the sales data of a company with respect to the four
dimensions, namely time, item, branch, and location.
Figure 24:Star Schema
There is a fact table at the center. It contains the keys to each of four dimensions.
The fact table also contains the attributes, namely dollars sold and units sold.
Note − each dimension has only one dimension table and each table holds a set of attributes.
For example, the location dimension table contains the attribute set {location_key, street,
city, province_or_state,country}. This constraint may cause data redundancy. For example,
"Vancouver" and "Victoria" both the cities are in the Canadian province of British
Columbia. The entries for such cities may cause data redundancy along the attributes
province_or_state and country.
Snowflake Schema
Some dimension tables in the Snowflake schema are normalized.
The normalization splits up the data into additional tables.
Unlike Star schema, the dimensions table in a snowflake schema are normalized. For
example, the item dimension table in star schema is normalized and split into two
dimension tables, namely item and supplier table.
Figure 25:Snowflake Schema
Now the item dimension table contains the attributes item_key, item_name, type,
brand, and supplier-key.
The supplier key is linked to the supplier dimension table. The supplier dimension
table contains the attributes supplier_key and supplier_type.
Note − Due to normalization in the Snowflake schema, the redundancy is reduced and
therefore, it becomes easy to maintain and the save storage space.
Schema Definition
Multidimensional schema is defined using Data Mining Query Language (DMQL). The two
primitives, cube definition and dimension definition, can be used for defining the data
warehouses and data marts.
Conclusion
At the end of this learning outcome, the learner should be able to explain decision support
systems, data mining, mobility and personal databases, spatial and geographical databases,
demonstrate distributed databases, illustrate multi-media databases, illustrate, design and
implement a data warehouse.
Further Reading
[Link]
2. Which of the following is storing a separate copy of the database at multiple locations?
A. Data Replication
B. Horizontal Partitioning
C. Vertical Partitioning
D. Horizontal and Vertical Partitioning
Oral Assessment
1. What is the difference between OLAP and OLTP?
2. Using the example of any business you are familiar with, outline how a data warehous
e might be used to identify trends that can help a business be competitive.
Practical Assessment
Consider a bank system with at least the following tables: Customer, branch, Withdrawals,
Deposits. Demonstrate how you can build a star schema for the bank system.
[Link] References
1. [Link]
2. [Link]