The document describes a database design project for an e-commerce system. It includes:
1) Logical and physical database designs showing the relationships between 11 tables. Table creation scripts are provided applying data integrity constraints.
2) Data generation and loading details where mock data was created and imported into the tables.
3) Seven SQL queries written to retrieve information from the tables such as most ordered inventory items, total shipments in a month, top selling items by price, top customers by purchase amount, orders with rejected payments, customers without orders, and users with many visits ordering high cost items.
4) Mention of a stored procedure being created to insert new inventory items with data validation checks.
With Endeca information discovery for Oracle Receivables User can review and analyze data using key Performance Indicators (KPIs), performance evaluation metrics, charts, graphs, and tables.
User can search using Receivables pages and Endeca Information Discovery (EID) design tools. These pages are hosted in an EID environment, and called from new container pages in EBS.
An Introduction to Oracle Warehouse Builder: Installation of the
database and OWB, About hardware and operating systems, Installing
Oracle database software, Configuring the listener, Creating the database,
Installing the OWB standalone software, OWB components and
architecture, Configuring the repository and workspaces.
Defining and Importing Source Data Structures: An overview of
Warehouse Builder Design Center, Importing/defining source metadata,
Creating a project, Creating a module, Creating an Oracle Database module,
Creating a SQL Server database module, Importing source metadata from a
database, Defining source metadata manually with the Data Object Editor,
Importing source metadata from files.
on SQL Managment studio(For the following exercise, use the Week 5.pdfformaxekochi
on SQL Managment studio
(For the following exercise, use the Week 5 DB Design Excel file. Place the completed file in the
zip folder with your .sql files)
A landscaping firm has tasked you with developing a database for their company. You have
gathered requirements and have come up with the following list of data elements to construct a
basic data structure:
Client name Invoice number Equipment description
Invoice date Job description Payment total
Client city Equipment purchase date Employee name
Invoice total Client address
Client phone Employee payrate
Client zip code Client state
a. Using the DB Design Excel file, do the following:
Name the tables using the drop down menu above each table grid
Add the appropriate fields to each table using the drop down menus within the fields of each
table
Choose the correct data type for each field using the drop down menus within the data type
column next to the field.
Example:
(Vendors) (Invoices) (InvoiceLineItems) VendorID InvoiceID InvoiceSequence
VendorName VendorID (FK to Vendors) InvoiceID (FK to Invoices)
VendorAddress InvoiceDate InvoiceLineItemAmount
VendorAddress2 InvoiceTotal
VendorCity
New Database:
Create a new database named Finances.
Write a script that creates the following tables with the listed attributes. Reference foreign keys
where indicated. Be sure to create the tables in order of their dependencies (if you attempt to
create a table with a reference to another table that hasn’t been created, the script will fail).
Register table
RegisterID INT PK IDENTITY NOT NULL
TransactionID
Transactions table INT FK NOT NULL
TransactionID INT PK IDENTITY NOT NULL
AccountID VARCHAR(25) FK NOT NULL
TransactionDate SMALLDATETIME NOT NULL
TransactionAmount
Account table MONEY NOT NULL
AccountID VARCHAR(25) PK NOT NULL
AccountName VARCHAR(50) NOT NULL
AccountAddress VARCHAR(30) NULL
AccountCity VARCHAR(25) NULL
AccountState CHAR(2) NULL
AccountZip VARCHAR(10) NULL
AccountPhone VARCHAR(14) NULL
Create a database diagram of the Finances database. Take a screenshot of the diagram and save
it as a png file.
if you receive an error message informing you that you don’t have permission for the database,
run the following query:
ALTER AUTHORIZATION ON DATABASE::Finances TO sa
GO
Write a script that creates non-clustered indexes on the foreign keys in the Register and
Transactions tables.
Write an ALTER TABLE statement that adds check constraints to the following columns (use
NOCHECK):
AccountPhone (NOT NULL)
TransactionAmount ( > 0 )
Write an ALTER TABLE statement that adds the follow columns to these tables:
Register table:
ReferenceNo
Transactions table: VARCHAR(15) NULL
TransactionType VARCHAR(15) NOT NULL
TransactionCredit BIT NULL
In the Object Explorer, do the following
Expand the Finances database
Expand the Tables folder
Expand each table
Expand the Columns folder for each table
Expand the Constraints folder for the Account and Transactions tables
Expand the Indexes folder for the Register and Tr.
With Endeca information discovery for Oracle Receivables User can review and analyze data using key Performance Indicators (KPIs), performance evaluation metrics, charts, graphs, and tables.
User can search using Receivables pages and Endeca Information Discovery (EID) design tools. These pages are hosted in an EID environment, and called from new container pages in EBS.
An Introduction to Oracle Warehouse Builder: Installation of the
database and OWB, About hardware and operating systems, Installing
Oracle database software, Configuring the listener, Creating the database,
Installing the OWB standalone software, OWB components and
architecture, Configuring the repository and workspaces.
Defining and Importing Source Data Structures: An overview of
Warehouse Builder Design Center, Importing/defining source metadata,
Creating a project, Creating a module, Creating an Oracle Database module,
Creating a SQL Server database module, Importing source metadata from a
database, Defining source metadata manually with the Data Object Editor,
Importing source metadata from files.
on SQL Managment studio(For the following exercise, use the Week 5.pdfformaxekochi
on SQL Managment studio
(For the following exercise, use the Week 5 DB Design Excel file. Place the completed file in the
zip folder with your .sql files)
A landscaping firm has tasked you with developing a database for their company. You have
gathered requirements and have come up with the following list of data elements to construct a
basic data structure:
Client name Invoice number Equipment description
Invoice date Job description Payment total
Client city Equipment purchase date Employee name
Invoice total Client address
Client phone Employee payrate
Client zip code Client state
a. Using the DB Design Excel file, do the following:
Name the tables using the drop down menu above each table grid
Add the appropriate fields to each table using the drop down menus within the fields of each
table
Choose the correct data type for each field using the drop down menus within the data type
column next to the field.
Example:
(Vendors) (Invoices) (InvoiceLineItems) VendorID InvoiceID InvoiceSequence
VendorName VendorID (FK to Vendors) InvoiceID (FK to Invoices)
VendorAddress InvoiceDate InvoiceLineItemAmount
VendorAddress2 InvoiceTotal
VendorCity
New Database:
Create a new database named Finances.
Write a script that creates the following tables with the listed attributes. Reference foreign keys
where indicated. Be sure to create the tables in order of their dependencies (if you attempt to
create a table with a reference to another table that hasn’t been created, the script will fail).
Register table
RegisterID INT PK IDENTITY NOT NULL
TransactionID
Transactions table INT FK NOT NULL
TransactionID INT PK IDENTITY NOT NULL
AccountID VARCHAR(25) FK NOT NULL
TransactionDate SMALLDATETIME NOT NULL
TransactionAmount
Account table MONEY NOT NULL
AccountID VARCHAR(25) PK NOT NULL
AccountName VARCHAR(50) NOT NULL
AccountAddress VARCHAR(30) NULL
AccountCity VARCHAR(25) NULL
AccountState CHAR(2) NULL
AccountZip VARCHAR(10) NULL
AccountPhone VARCHAR(14) NULL
Create a database diagram of the Finances database. Take a screenshot of the diagram and save
it as a png file.
if you receive an error message informing you that you don’t have permission for the database,
run the following query:
ALTER AUTHORIZATION ON DATABASE::Finances TO sa
GO
Write a script that creates non-clustered indexes on the foreign keys in the Register and
Transactions tables.
Write an ALTER TABLE statement that adds check constraints to the following columns (use
NOCHECK):
AccountPhone (NOT NULL)
TransactionAmount ( > 0 )
Write an ALTER TABLE statement that adds the follow columns to these tables:
Register table:
ReferenceNo
Transactions table: VARCHAR(15) NULL
TransactionType VARCHAR(15) NOT NULL
TransactionCredit BIT NULL
In the Object Explorer, do the following
Expand the Finances database
Expand the Tables folder
Expand each table
Expand the Columns folder for each table
Expand the Constraints folder for the Account and Transactions tables
Expand the Indexes folder for the Register and Tr.
A story about developing an application for an online store, persisting all the data as JSON.
Gives an overview of JSON functionality in Oracle Database 19c.
CakePHP is a nice way of using MVC architecture in you PHP environment. Looking through this presentation you'll get introduced to MVC and get some start up code examples for you to explore.
Dynamics GP includes integrated manufacturing functionality that includes bills of materials, MRP, manufacturing orders, in-bound quality management, sales forecast management. You can utilize back flush or work in process processing. This document includes tips and tricks that you might not ordinarily find or know about.
This ppt is about Orm and hibernate. This ppt gives you a brief knowledge about orm and hibernate. For more info visit : http://s4al.com/category/study-java/
Joining the Club: Using Spark to Accelerate Big Data at Dollar Shave ClubData Con LA
Abstract:-
Data engineering at Dollar Shave Club has grown significantly over the last year. In that time, it has expanded in scope from conventional web-analytics and business intelligence to include real-time, big data and machine learning applications. We have bootstrapped a dedicated data engineering team in parallel with developing a new category of capabilities. And the business value that we delivered early on has allowed us to forge new roles for our data products and services in developing and carrying out business strategy. This progress was made possible, in large part, by adopting Apache Spark as an application framework. This talk describes what we have been able to accomplish using Spark at Dollar Shave Club.
Bio:-
Brett Bevers, Ph.D. Brett is a backend engineer and leads the data engineering team at Dollar Shave Club. More importantly, he is an ex-academic who is driven to understand and tackle hard problems. His latest challenge has been to develop tools powerful enough to support data-driven decision making in high value projects.
A story about developing an application for an online store, persisting all the data as JSON.
Gives an overview of JSON functionality in Oracle Database 19c.
CakePHP is a nice way of using MVC architecture in you PHP environment. Looking through this presentation you'll get introduced to MVC and get some start up code examples for you to explore.
Dynamics GP includes integrated manufacturing functionality that includes bills of materials, MRP, manufacturing orders, in-bound quality management, sales forecast management. You can utilize back flush or work in process processing. This document includes tips and tricks that you might not ordinarily find or know about.
This ppt is about Orm and hibernate. This ppt gives you a brief knowledge about orm and hibernate. For more info visit : http://s4al.com/category/study-java/
Joining the Club: Using Spark to Accelerate Big Data at Dollar Shave ClubData Con LA
Abstract:-
Data engineering at Dollar Shave Club has grown significantly over the last year. In that time, it has expanded in scope from conventional web-analytics and business intelligence to include real-time, big data and machine learning applications. We have bootstrapped a dedicated data engineering team in parallel with developing a new category of capabilities. And the business value that we delivered early on has allowed us to forge new roles for our data products and services in developing and carrying out business strategy. This progress was made possible, in large part, by adopting Apache Spark as an application framework. This talk describes what we have been able to accomplish using Spark at Dollar Shave Club.
Bio:-
Brett Bevers, Ph.D. Brett is a backend engineer and leads the data engineering team at Dollar Shave Club. More importantly, he is an ex-academic who is driven to understand and tackle hard problems. His latest challenge has been to develop tools powerful enough to support data-driven decision making in high value projects.
Gen Z and the marketplaces - let's translate their needsLaura Szabó
The product workshop focused on exploring the requirements of Generation Z in relation to marketplace dynamics. We delved into their specific needs, examined the specifics in their shopping preferences, and analyzed their preferred methods for accessing information and making purchases within a marketplace. Through the study of real-life cases , we tried to gain valuable insights into enhancing the marketplace experience for Generation Z.
The workshop was held on the DMA Conference in Vienna June 2024.
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBrad Spiegel Macon GA
Brad Spiegel Macon GA’s journey exemplifies the profound impact that one individual can have on their community. Through his unwavering dedication to digital inclusion, he’s not only bridging the gap in Macon but also setting an example for others to follow.
Understanding User Behavior with Google Analytics.pdfSEO Article Boost
Unlocking the full potential of Google Analytics is crucial for understanding and optimizing your website’s performance. This guide dives deep into the essential aspects of Google Analytics, from analyzing traffic sources to understanding user demographics and tracking user engagement.
Traffic Sources Analysis:
Discover where your website traffic originates. By examining the Acquisition section, you can identify whether visitors come from organic search, paid campaigns, direct visits, social media, or referral links. This knowledge helps in refining marketing strategies and optimizing resource allocation.
User Demographics Insights:
Gain a comprehensive view of your audience by exploring demographic data in the Audience section. Understand age, gender, and interests to tailor your marketing strategies effectively. Leverage this information to create personalized content and improve user engagement and conversion rates.
Tracking User Engagement:
Learn how to measure user interaction with your site through key metrics like bounce rate, average session duration, and pages per session. Enhance user experience by analyzing engagement metrics and implementing strategies to keep visitors engaged.
Conversion Rate Optimization:
Understand the importance of conversion rates and how to track them using Google Analytics. Set up Goals, analyze conversion funnels, segment your audience, and employ A/B testing to optimize your website for higher conversions. Utilize ecommerce tracking and multi-channel funnels for a detailed view of your sales performance and marketing channel contributions.
Custom Reports and Dashboards:
Create custom reports and dashboards to visualize and interpret data relevant to your business goals. Use advanced filters, segments, and visualization options to gain deeper insights. Incorporate custom dimensions and metrics for tailored data analysis. Integrate external data sources to enrich your analytics and make well-informed decisions.
This guide is designed to help you harness the power of Google Analytics for making data-driven decisions that enhance website performance and achieve your digital marketing objectives. Whether you are looking to improve SEO, refine your social media strategy, or boost conversion rates, understanding and utilizing Google Analytics is essential for your success.
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdfFlorence Consulting
Quattordicesimo Meetup di Milano, tenutosi a Milano il 23 Maggio 2024 dalle ore 17:00 alle ore 18:30 in presenza e da remoto.
Abbiamo parlato di come Axpo Italia S.p.A. ha ridotto il technical debt migrando le proprie APIs da Mule 3.9 a Mule 4.4 passando anche da on-premises a CloudHub 1.0.
Italy Agriculture Equipment Market Outlook to 2027harveenkaur52
Agriculture and Animal Care
Ken Research has an expertise in Agriculture and Animal Care sector and offer vast collection of information related to all major aspects such as Agriculture equipment, Crop Protection, Seed, Agriculture Chemical, Fertilizers, Protected Cultivators, Palm Oil, Hybrid Seed, Animal Feed additives and many more.
Our continuous study and findings in agriculture sector provide better insights to companies dealing with related product and services, government and agriculture associations, researchers and students to well understand the present and expected scenario.
Our Animal care category provides solutions on Animal Healthcare and related products and services, including, animal feed additives, vaccination
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC
Ellisha Heppner, Grant Management Lead, presented an update on APNIC Foundation to the PNG DNS Forum held from 6 to 10 May, 2024 in Port Moresby, Papua New Guinea.
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
Adbms final group project report
1. ISM6218.001F16
ADVANCED DATABSE MANAGEMENT SYSTEMS
FINAL GROUP PROJECT
“E-COMMERCE SYSTEMS”
Group Members
Himank Vats (U87964346)
Jijo Johny (U12605351)
Tess Thomas (U66417789)
Vrishali Giri (U40856469)
2. CONTENTS
Executive Summary
Assumptions
Part 1: Database Design
Section 1.1: Data Integrity
Section 1.2: Data Generation and Loading
Section 1.3: Logical Database Design
Section 1.3: Physical Database Design
Part 2: Query Writing
Section 2.1: SQL Queries
Section 2.2: Database Programming
Part 3: Performance Tuning
Section 3.1: Indexing
Section 3.2: Parallelism
Part 4: Other Topics
Section 4.1: DBA scripts
Section 4.2: Database Security
3. Executive Summary
The use of internet technology for performing business transaction has grown
exponentially over the decade or so. Almost all companies have migrated their
transactions to e-commerce and remaining ones are on their way to do so! While B2B
ecommerce platforms are making billions of revenues, B2C has become successful in
establishing good relation with huge consumer followers nonetheless.
The rise of online shopping have turned shoppers into promiscuous deal-hunters armed
with mobile technology that allows them to shop whenever they want, however they
want with whomever they want.
4. The goal of this project is to build an E-Commerce system for online shoppers giving them
flexibility to shop their favourite items without having to visit any shop. An e-commerce
value chain represents a set of sequences which involves the interactions between online
shoppers and e-commerce systems. We have focused on easy-to-understand user
interface and query optimization in order to reduce the query processing time and give a
user an hasslefree shopping experience. User role privileges are assigned in order to
restrict the access between normal user and administrator. The system will generate up-
to-date data based on number of items sold, availabe inventory and changes in prices.
Below is the weights distribution according to the areas covered –
Topic Area Description Points
Database Design
- Data Integrity
- Data Generation and Loading
- Logical Database Design
- Physical Database Design
30
Query Writing
- SQL Queries
- Stored Procedure
25
Performance Tuning
- Indexing
- Parallelism
30
Other Topics
- DBA scripts
- Database security
15
5. Assumptions
1. INV_Item_Number from the Inventory Item table should be present in the Order
Item but not as foreign key. Because if it is declared as foreign key then the
referential integrity will be violated when INV_Item_Number from the Inventory
Item table is deleted.
2. Join ORDER_ITEM and INVENTORY_ITEM by outer join rather than a natural join so
that order item with deleted product will be included.
3. Credit card table has the 16-digit credit number as primary key this it is unique.
4. Order table provides detail on products and how many were ordered for a given
invoice.
5. Residential and shipping address are stored for customers.
6. Customers can have multiple credit cards tied to their account. It can be different
names and billing address.
7. Invoice contains the order details, shipping information and address of customer.
6. Part 1: Database Design
Section 1.1 : Logical Database Design
Below relational diagram depicts the interrelations between all the database tables. The
se relationships are established by defining foreign key constraints.
7. Section 1.2 : Physical Database Design
We have generated below relational diagram using SQL developer modeler function.
8. Section 1.3 : Data Integrity
Below are the backend table creation queries which we have used.
A. INVENTORY_ITEM
CREATE TABLE "DB215"."INVENTORY_ITEM"
( "INV_ITEM" NUMBER(5,0) NOT NULL ENABLE,
"INV_TITLE" VARCHAR2(6 BYTE) NOT NULL ENABLE,
"INV_PRICE" NUMBER(5,0),
"INV_TIMESTAMP" DATE,
CONSTRAINT "INV_ITEM_PK" PRIMARY KEY ("INV_ITEM") );
18. K. SHIPPING
CREATE TABLE "DB215"."SHIPPING"
( "SHIPPING_NUMBER" NUMBER(5,0) NOT NULL ENABLE,
"ORDER_ID" NUMBER(5,0) NOT NULL ENABLE,
"INVOICE_NUMBER" NUMBER(5,0) NOT NULL ENABLE,
"SHIPPING_METHOD" VARCHAR2(255 BYTE) NOT NULL ENABLE,
"SHIPPING_CHARGE" NUMBER(5,0) NOT NULL ENABLE,
"ZIP" NUMBER(5,0),
"SHIPPING_DATE" DATE NOT NULL ENABLE,
"ADDRESS_NUMBER" NUMBER(5,0),
CONSTRAINT "SHIPPING_NUMBER_PK" PRIMARY KEY ("SHIPPING_NUMBER")
CONSTRAINT "SHIPPING_ORDER_ID_FK" FOREIGN KEY ("ORDER_ID")
REFERENCES "DB215"."ORDERS" ("ORDER_ID") ENABLE,
CONSTRAINT "SHIP_INVOICE_NUMBER_FK" FOREIGN KEY ("INVOICE_NUMBER")
REFERENCES "DB215"."INVOICE" ("INVOICE_NUMBER") ENABLE,
CONSTRAINT "ADDRESS_NUMBER_FK2" FOREIGN KEY ("ADDRESS_NUMBER")
REFERENCES "DB215"."USER_INFO" ("ADDRESS_NUMBER") ENABLE );
19. Section 1.4 : Data Generation and Loading
A. Data Generation
The database design has 11 tables and the data is generate dfor all of them.
The user account table includes user_id, password, number of visits, total
transaction amount.
Shipping information can be tracked form the shipping table.
Payment information can be tracked from the payment table.
The table user_session has 1000 rows rest all the tables 5000 rows each.
The external data is created using:
https://www.mockaroo.com
http://www.yandataellan.com
The user_session data has been created using the online generator as shown in the
above snapshot. We can select the data type for each attribute value as specified
in the data base design and download the csv format using the download button.
20. Here the session_id is created as random number ranging from 80000 to 87000,
session_clicks as number ranging from 1 to 10, session time ranging from
11/10/2015 to 11/10/2016 and session_ip_address as ip address v4. Using this we
can generate 1000 rows.
Below is the screenshot for creating tables with 5000 rows each.
21. B. Data Loading
All the required data is initially generated using the external data generator and is
stored in the spreadsheets. Data is then imported to SQL developer using the
import feature.
Following are steps to import data to table:
1. Right click on the table and select “import data”.
2. Select the spread sheet containing data.
3. Select the format and spread sheet in the xls file (select headers).
4. Import method is insert.
5. Add all the columns required from file.
6. Map all the columns in spread sheet to columns in the database.
7. Verify parameters before import.
8. If the verification is successful, click finish to import the data.
Below images shows the data import wizard and the way the data in imported into
the INVENTORY_ITEM table.
22. Right click on the table and select “import data”
Data Import Wizard
23. Data Preview in Data Import Wizard
Choose Column in Data import Wizard
24. Column Definition in Data import Wizard
Column Definition for Inventory_Item Table in Data import Wizard
25. Final Step in Data Import Wizard
Data imported successful!
27. The number of record in each table is shown below:
Table Number of Tuples
INVENTORY_ITEM 5000
ORDER_ITEM 5000
INVOICE 5000
USER_SESSION 1000
USER_ACCOUNT 5000
CREDIT_CARD 5000
SHOPPING_CART 5000
ORDERS 5000
PAYMENT 5000
USER_INFO 5000
SHIPPING 5000
28. Part 2: Query Writing
Section 2.1: SQL Queries
Query 1: Inventory item which is most ordered.
SELECT INVENTORY_ITEM.INV_TITLE AS NAME, SUM(SHOPPING_CART.QTY) AS
TOTAL_QUANTITY
FROM SHOPPING_CART
INNER JOIN INVENTORY_ITEM
ON SHOPPING_CART.INV_ITEM = INVENTORY_ITEM.INV_ITEM
GROUP BY INVENTORY_ITEM.INV_TITLE
ORDER BY SUM(SHOPPING_CART.QTY)DESC;
29. Query 2: Total shipments done in month of march.
SELECT COUNT (SHIPPING_NUMBER)
FROM SHIPPING
WHERE SHIPPING_DATE BETWEEN '1/3/2016' AND '31/3/2016';
Query 3: Top selling items by Price.
SELECT INVENTORY_ITEM.INV_TITLE AS NAME ,SUM(INVENTORY_ITEM.INV_PRICE) AS
SALES, SUM(SHOPPING_CART.QTY) AS QUANTITY
FROM SHOPPING_CART
INNER JOIN INVENTORY_ITEM
ON SHOPPING_CART.INV_ITEM = INVENTORY_ITEM.INV_ITEM
GROUP BY INVENTORY_ITEM.INV_TITLE
ORDER BY SUM(INVENTORY_ITEM.INV_PRICE)DESC;
30. Query 4: Top Customers by Purchase Amount
SELECT UA.ACC_NUMBER,UA.ACC_ID, SUM(O.TOTAL_AMT) AS PURCHASES
FROM ORDERS O
INNER JOIN USER_ACCOUNT UA
ON O.ACC_NUMBER=UA.ACC_NUMBER
GROUP BY UA.ACC_NUMBER,UA.ACC_ID
ORDER BY SUM(O.TOTAL_AMT)DESC;
31. Query 5: All the orders with rejected payment
SELECT O.ORDER_ID, O.ORDER_DATE, O.TOTAL_AMT
FROM ORDERS O
JOIN PAYMENT P
ON O.ORDER_ID=P.ORDER_ID
WHERE P.STATES= 'FALSE' OR P.STATES='Failed'
ORDER BY O.TOTAL_AMT;
32. Query 6: Customers who haven’t placed any orders so far
SELECT UA.ACC_NUMBER, UA.ACC_ID
FROM ORDERS O
RIGHT OUTER JOIN USER_ACCOUNT UA
ON O.ACC_Number=UA.ACC_NUMBER
WHERE O.ACC_NUMBER IS NULL
GROUP BY UA.ACC_NUMBER, UA.ACC_ID
ORDER BY UA.ACC_NUMBER ;
33. Query 7: Users with more than 100 visits and have ordered high cost Items
SELECT UA.ACC_NUMBER, UA.ACC_ID, II.INV_PRICE
FROM USER_ACCOUNT UA
JOIN USER_SESSION US
ON UA.SESSION_ID = US.SESSION_ID
JOIN SHOPPING_CART SC
ON US.CART_ID = SC.CART_ID
JOIN INVENTORY_ITEM II
ON SC.INV_ITEM = II.INV_ITEM
WHERE UA.ACC_VISITS > 100
ORDER BY II.INV_PRICE DESC;
34. Section 2.2: Database Programming / Stored Procedures
Stored procedures in DBMS are group of SQL statements integrated with a programming
block, which can be named and stored in backend. Stored procedures can be shared and
invoked by their name from any program.
Below stored procedure is created to insert new items in inventory. The procedure performs
check on USER_ROLE value from table USER_ACCOUNT before inserting record into the table
If the user is ‘Admin’, only then the insertion is allowed. Procedure will come out of the loop
if the role is other than ‘Admin’. In other words, every time Administrator tries to insert new
record in INVENTORY_ITEM table, procedure ‘UpdateInventory’ is invoked.
35. Part 3: Performance Tuning
Section 3.1: Indexing
Indexing is an essential part of performance tuning in database design. It helps improving
the performance of query. We have used 2 types of indexing techniques while designing
database - B-Tree and Bitmap Indexing.
Before we begin explicitely creating indexes on tables, let us first take a look at current
status of indexes in our database.
The below query will extract the index structure from database schema.
As we can see, currently we have only primary key index type which was assigned while
creating tables. We will focus on tables those are densly populated and try to take a
measurable stance to improve the query retrival time to some extent.
36. B-Tree Index
Let us execute the below complex query without creating any explicit index on tables.
As we can see, the query execution time is 0.062 seconds and the cost of query is 21.
37. We decided to create a B-Tree index on table ORDER_ITEM and on column ORDER_ID.
Post index creation, we executed the same query again. We could see that this time the
query took only 0.072 seconds to fetch data and query cost is reduced to 13.
38. B-trees are the most widely used index type and a ubiquitous structure in computer
science. Let us now create Bitmap index on comparatively densed table and observe the
outcome.
39. Bitmap Index
Bitmap index structure uses bit-vector concept to indiacte which of the values occur in a
row.
Below query is executed without creating any index on tables used.
As we can see, the query execution took 2.21 seconds with the cost of query as 31.
40. We have created bitmap index on CREDIT_CARD table as below.
As we can see, the query execution time reduced to 0.21 secinds whereas query cost
has reduced to 21.
41.
42. Section 3.2: Parallelism
Parallel processing is used to speed up datbase operations. We can apply parallelism to
a single query to attain high speed. Parallelism is a natural fit for relational database
environment.
Step 1: Run the query
select acc_number,acc_password,acc_visits,session_id
from user_account;
Step 2: Alter the table to use parallelism.
ALTER TABLE user_Account PARALLEL (DEGREE 4);
Step 3: Run the query again and look at the new execution plan.
43.
44. Part 4: Other Topics
Section 4.1: DBA scripts
DBA scripts are an excellent ways to query data dictionary in order to better understand
what’s happening inside the database engine.
Below are few types of scripts an administrator can use in his routine checks.
A. Script 1
The below query will give the active sessions of the database. This is useful to monitor t
he database and to ensure the security of database.
SELECT NVL(s.username, '(oracle)') AS username,
s.osuser, s.sid,
p.spid, s.serial#,
s.lockwait, s.status,
s.service_name, s.module,
s.program,s.machine,
TO_CHAR(s.logon_Time,'DD-MON-YYYY HH24:MI:SS') AS login_time
FROM v$session s,
v$process p
WHERE s.paddr = p.addr
ORDER BY login_time;
45. B. Script 2
The below script displays the free space per data file. This is useful for monitoring the
datafiles when the storage is limited and this would help assimilate new datafiles.
Select df.tablespace_name,
df.file_name,
df.bytes/1024/1024 total_size,
nvl(fr.bytes/1024/1024,0) free_space,
((df.bytes-nvl(fr.bytes,0))/df.bytes)*100 pct_used
from (select sum(bytes) bytes,
file_id
from dba_free_space
group by file_id) fr,
dba_data_files df
where df.file_id = fr.file_id(+)
order by 1, df.file_id;
46. C. Script 3
It shows the background proccess that are running currently in database instance.
SELECT *
FROM v$bgprocess
WHERE PADDR <> '00'
ORDER BY DESCRIPTION;
47. D. Script 4
This script displays the blocks and data size of users.
SELECT OWNER,
SUM(BLOCKS) TOTALBLOCKS,
SUM(BYTES/(1024*1024)) TOTALMB
FROM DBA_SEGMENTS
GROUP BY OWNER
ORDER BY totalblocks;
E. Script 5
The below script displays the partitioning information. Partitioning helps in increasing
the availability of mission critical databse. Critical tables or indexes are divided into
partitions to reduce maintenance windows or recovery times or failures.
SELECT p.table_name,
p.partition_name,
49. G. Script 7
This script is to kill session. Before killing the session we have to identify the
session that needs to be killed, if we kill the wrong session this can be very
destructive. If a session belonging to a background process is killed this would
cause an instance crash. To identify the session offending:
SELECT s.inst_id,
s.sid,
s.serial#,
p.spid,
s.username,
s.program
FROM gv$session s
JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id
WHERE s.type != 'BACKGROUND';
50.
51. Section 4.2: Database Security
Data security will be applied to ensure that no unauthorized user can edit any critical
data from the USER ACCOUNT, PAYMENT, INVENTORY ITEM, ORDER ITEM, ORDER
DETAILS, SHIPPING, INVOICE, CREDIT CARD, SHOPPING CART, ADDRESS and USER
SESSION tables.
Roles will be assigned to all the players, security will be given to the users based on their
roles. Sensitive and confidential data has to be encrypted.
Encryption helps in preventing unauthorized access to both static as well as dynamic
data even if the data is copied, backed up or stored offline.
Data access is controlled rather than than database access.
Data redaction strategies are another useful way of controlling access to data. It masks
data at query time, so that the rules are aplied on the data being progressed.
User authentication is a way to control database access in Oracle DBMS and other
database systems. The three components are: users that must authenticate to access
the database, system and object privileges to further control access and finally roles that
can be used to organize groups of privileges.
Privileges that are only necessary are given to other users.
Without roles, granting privileges directly to individual and separate users would create
a confusing and unwieldy network of access rights.
A person with admin_role as ‘Administrator’ is only authorized to update all the
information from all the tables.
52. Granting authentication for roles:
Grant All on USER ACCOUNT for ‘Administrator’;
Grant All on PAYMENT for ‘Administrator’;
Grant All on INVENTORY ITEM for ‘Administrator’;
Grant All on ORDER ITEM for ‘Administrator’;
Grant All on ORDER DETAILS for ‘Administrator’;
Grant All on SHIPPING for ‘Administrator’;
Grant All on INVOICE for ‘Administrator’;
Grant All on CREDIT CARD for ‘Administrator’;
Grant All on SHOPPING CART for ‘Administrator’;
Grant All on ADDRESS for ‘Administrator’;
Grant All on USER SESSION for ‘Administrator’.