Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need a fact _ table with columns of Store _ ID , Perscription ID , Brand _ ID and Quanity ordered. How do I

I need a fact
_
table with columns of Store
_
ID
,
Perscription ID
,
Brand
_
ID and Quanity ordered. How do I script that to create it and how do I script the data to insert How do I put it together I am lost. I have the data but I can't seem to figure out how to do it I have done this but I can't add it to a fact table. CREATE TABLE [3NF_PATIENT](
ID INT PRIMARY KEY,
NAME VARCHAR(100),
ADDRESS VARCHAR(100),
CITY VARCHAR(50),
STATE CHAR(2));
INSERT INTO [3NF_PATIENT](ID, NAME, ADDRESS, CITY, STATE) VALUES
(1258, 'Matt Smith', '203 Norht Hazel', 'Glenwood', 'IA'),
(2258, 'John Blue', '40 South', 'Omaha', 'NE'),
(2245, 'Pete Jones', '78 North Maple', 'Chicago', 'IL'),
(2236, 'Bill Powers', '10 Dodge', 'Chicago', 'IL'),
(2367, 'Mark Bagg', '234 Elm', 'Manhattan', 'KS'),
(5523, 'Jim Dau', '445 Oak Street', 'New York', 'NY'),
(3335, 'Luke stier', '999 Maple', 'Tabor', 'IA'),
(3369, 'Emma Dier', '3349 Happs', 'Omaha', 'NE'),
(2228, 'Colleen Riek', '3999 Sams', 'Carroll', 'I');
SELECT * FROM [3NF_PATIENT]
CREATE TABLE [3NF_DRUG](
ID INT,
DRUG_NAME VARCHAR(255),
CODE_1 VARCHAR(10),
CODE_2 VARCHAR(10),
YEAR INT,
DEPARTMENT VARCHAR(255),
CODE_3 VARCHAR(10),
CATEGORY VARCHAR(255),
VALUE_1 DECIMAL(10,2),
VALUE_2 INT,
VALUE_3 DECIMAL(10,2),
PRIMARY KEY (ID, CODE_1, CODE_2, YEAR)
);
-- Insert data into the 'medications' table
INSERT INTO [3NF_DRUG](ID, DRUG_NAME, CODE_1, CODE_2, YEAR, DEPARTMENT, CODE_3, CATEGORY, VALUE_1, VALUE_2, VALUE_3) VALUES
(12958, 'Heart Clear', '2345','B4456',1995, 'Cardiology', 'F4456', 'Whole Body', 34.56,10,78.56),
(12958, 'Heart Clear', '2345','B4444',1995, 'Cardiology', 'F4456', 'Whole Body', 34.56,40,78.56),
(12958, 'Heart Clear', '5555','B1111',1995, 'Cardiology', 'F4456', 'Whole Body', 34.56,5,78.56),
(13333, 'Lung Guard', '2345','B1452',1556, 'Pulmonary', 'B3458', 'Lung Health', 10.56,234,123.56),
(13333, 'Lung Guard', '5555','B3333',1556, 'Pulmonary', 'B3458', 'Lung Health', 10.56,34,123.56),
(13333, 'Lung Guard', '1111','B4444',1556, 'Pulmonary', 'B3458', 'Lung Health', 10.56,12,123.56),
(15555, 'Lung Work', '2345','B5674',1556, 'Pulmonary', 'B3458', 'Lung Health', 2.56,99,34.11),
(15555, 'Lung Work', '1111','B5677',1556, 'Pulmonary', 'B3458', 'Lung Health', 2.56,44,34.11),
(15555, 'Lung Work', '2345','B5671',1556, 'Pulmonary', 'B3458', 'Lung Health', 2.56,17,34.11),
(33333, 'Nervous Help', '2345','B5767',1337, 'Nervous', 'W3456', 'Nervous Support', 55.11,10,44.11),
(33333, 'Nervous Help', '3345','B5769',1338, 'Nervous II','W3456', 'Nervous Support', 22.11,14,44.11);
SELECT * FROM [3NF_DRUG]
-- Create a table called 'records'
CREATE TABLE [3NF_PERSCRIPTIONS](
CODE VARCHAR(10),
DATE DATE,
ID INT,
VALUE_1 INT,
VALUE_2 INT
);
-- Insert data into the 'records' table
INSERT INTO [3NF_PERSCRIPTIONS](CODE, DATE, ID, VALUE_1, VALUE_2) VALUES
('B4456','2015-04-15',1258,12,35),
('B4443','2015-01-13',2258,40,78),
('B1111','2015-02-13',2245,5,78),
('B1452','2015-03-01',2236,10,123),
('B3333','2015-06-12',2236,34,123),
('B4444','2015-08-01',2236,10,12),
('B5674','2015-07-14',2367,2,99),
('B5677','2015-07-16',5523,2,44),
('B5671','2015-04-01',3335,17,34),
('B5767','2015-12-12',3369,10,11),
('B5769','2015-11-23',2228,55,441);
SELECT * FROM [3NF_PERSCRIPTIONS]
-- Create a table called 'stores'
CREATE TABLE [3NF_STORES](
CODE INT,
STORE_NAME VARCHAR(25

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Microsoft SQL Server 2012 Programming

Authors: Paul Atkinson, Robert Vieira

1st Edition

1118102282, 9781118102282

More Books

Students also viewed these Databases questions

Question

6 How can an organisation increase its flexibility?

Answered: 1 week ago

Question

1.6 Identify ways that country culture influences global business.

Answered: 1 week ago