CS363: Structured Query Language for Data Management 1. CS363: Structured Query Language (SQL) for Data Management. Team Echo Group Project - Final
|
|
- August Edwards
- 6 years ago
- Views:
Transcription
1 CS363: Structured Query Language for Data Management 1 CS363: Structured Query Language (SQL) for Data Management Team Echo Group Project - Final Trina VanderLouw Other Team Members: Darrell Moore, Kanaan Pitts, Curtis Rice Professor Sabahudin Tricic Colorado Technical University Online April 16, 2012 Highlights: Group Project, SQL, Statements/Queries, Users, Roles, Permissions Programs Used: MySQL, Access, SQL Server, Word, Power Point Instructor Feedback: Thank you for participating this week. This assignment was geared to see how well you understand the decision making process and its implementation through various database decisions that are made while programming. By giving examples of how they work, you showcased your knowledge of how these constructs operate and how team members pick the set up. Keep working hard! Sabahudin Tricic Feedback on Group: Team E, great job on this project, even though only two members were truly active. I was very impressed by the amount of communication, and the effort that was put into the organization of your project. The active members of this team gave his or her best, and the results show that--your final project is of highest quality and would be well accepted in the workplace. It is very accessibile and clear--i especially liked the contents page in terms of your organization. Thank you for including me in your s--great team communication between the active members (Darrell and Trina). Final Grade: A
2 CS363: Structured Query Language for Data Management 2 TABLE OF CONTENTS INTRODUCTION/ABTRACT... 3 SCREEN SHOT OF A ENTITY RELATIONSHIP DIAGRAM (ERD)... 3 DATABASE SCRIPT FOR TABLE CREATION... 4 DCL STATEMENTS FOR LOGIN, USER, ROLES, AND PRIVILEGES (SECTION 1)... 9 REPORT REQUEST QUERIES (SECTION 2) INDEXES AND SCRIPTS (SECTION 3) STORED PROCEDURE (SECTION 4) CONCLUSION REFERENCES... 19
3 CS363: Structured Query Language for Data Management 3 INTRODUCTION/ABTRACT COMPLETED BY: Darrell Moore Canine Caper's Inc (CCI) has accepted our firms solicited proposal. Within that proposal our firm prescribed a solution that incorporated a Relational Database deployed over a Wide Area Network (WAN). This document is to serve as the proposal for the CCI database design. As such, this document includes the CCI database ERD, the scripts necessary to build the CCI database, the scripts necessary to build CCI's users, roles, logins, and privileges, example report queries, functional indexes and scripts, and necessary stored procedures (CS363, 2012). SCREEN SHOT OF A ENTITY RELATIONSHIP DIAGRAM (ERD) Here is a screen shot of the proposed CCI database ERD: Figure 1.1
4 CS363: Structured Query Language for Data Management 4 DATABASE SCRIPT FOR TABLE CREATION Script 1 Categories Table: USE [CCI] /****** Object: Table [dbo].[categories] Script Date: 04/11/ :26:32 ******/ SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON SET ANSI_PADDING ON CREATE TABLE [dbo].[categories]( [CategoryID] [int] IDENTITY(1,1) NOT NULL, [CatName] [varchar](50) NOT NULL, [CatDescription] [text] NOT NULL, CONSTRAINT [PK_Categories] PRIMARY KEY CLUSTERED ( [CategoryID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] SET ANSI_PADDING OFF Script 2 Customers Table: USE [CCI] /****** Object: Table [dbo].[customers] Script Date: 04/11/ :33:39 ******/ SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON SET ANSI_PADDING ON CREATE TABLE [dbo].[customers]( [CustomerID] [int] IDENTITY(1,1) NOT NULL, [CusCompanyName] [varchar](50) NOT NULL, [CusContactLastName] [varchar](50) NOT NULL, [CusContactFirstName] [varchar](50) NOT NULL, [CusCompanyAddress] [varchar](200) NOT NULL, [CusCompanyCity] [varchar](50) NOT NULL, [CusCompanyState] [varchar](50) NOT NULL, [CusCompanyPostalCode] [varchar](50) NOT NULL, [CusCompanyCountry] [varchar](50) NOT NULL, [CusCompanyPhoneNumber] [varchar](50) NOT NULL, [CusContact Address] [varchar](150) NOT NULL, CONSTRAINT [PK_Customers] PRIMARY KEY CLUSTERED ( [CustomerID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] SET ANSI_PADDING OFF
5 CS363: Structured Query Language for Data Management 5 Script 3 Employees Table: USE [CCI] /****** Object: Table [dbo].[employees] Script Date: 04/11/ :35:05 ******/ SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON SET ANSI_PADDING ON CREATE TABLE [dbo].[employees]( [EmployeeID] [int] IDENTITY(1,1) NOT NULL, [EmpLastName] [varchar](50) NOT NULL, [EmpFirstName] [varchar](50) NOT NULL, [EmpTitle] [varchar](50) NOT NULL, [EmpHireDate] [date] NOT NULL, [EmpAddress] [varchar](50) NOT NULL, [EmpCity] [varchar](50) NOT NULL, [EmpState] [varchar](50) NOT NULL, [EmpPostalCode] [varchar](50) NOT NULL, [EmpCountry] [varchar](50) NOT NULL, [EmpHomePhone] [varchar](50) NOT NULL, [EmpCellPhone] [varchar](50) NULL, [Emp ] [varchar](50) NOT NULL, CONSTRAINT [PK_Employees] PRIMARY KEY CLUSTERED ( [EmployeeID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] SET ANSI_PADDING OFF Script 4 Inventory Table: USE [CCI] /****** Object: Table [dbo].[inventory] Script Date: 04/11/ :40:51 ******/ SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON CREATE TABLE [dbo].[inventory]( [InventoryID] [int] IDENTITY(1,1) NOT NULL, [InvProductID] [int] NOT NULL, [InvCurrentInStock] [int] NOT NULL, [InvMaximumLevel] [int] NOT NULL, [InvMinimumLevel] [int] NOT NULL, [InvDiscontinued] [bit] NOT NULL, CONSTRAINT [PK_Inventory] PRIMARY KEY CLUSTERED ( [InventoryID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]
6 CS363: Structured Query Language for Data Management 6 ALTER TABLE [dbo].[inventory] WITH CHECK ADD CONSTRAINT [FK_Inventory_Products] FOREIGN KEY([InvProductID]) REFERENCES [dbo].[products] ([ProductID]) ALTER TABLE [dbo].[inventory] CHECK CONSTRAINT [FK_Inventory_Products] Script 5 Orders Table: USE [CCI] /****** Object: Table [dbo].[orders] Script Date: 04/11/ :42:24 ******/ SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON CREATE TABLE [dbo].[orders]( [OrderID] [int] IDENTITY(1,1) NOT NULL, [OrdCustomerID] [int] NOT NULL, [OrdEmployeeID] [int] NOT NULL, [OrdProductID] [int] NOT NULL, [OrdQuantity] [int] NOT NULL, [OrdShipperID] [int] NOT NULL ) ON [PRIMARY] ALTER TABLE [dbo].[orders] WITH CHECK ADD CONSTRAINT [FK_Orders_Customers] FOREIGN KEY([OrdCustomerID]) REFERENCES [dbo].[customers] ([CustomerID]) ALTER TABLE [dbo].[orders] CHECK CONSTRAINT [FK_Orders_Customers] ALTER TABLE [dbo].[orders] WITH CHECK ADD CONSTRAINT [FK_Orders_Employees] FOREIGN KEY([OrdEmployeeID]) REFERENCES [dbo].[employees] ([EmployeeID]) ALTER TABLE [dbo].[orders] CHECK CONSTRAINT [FK_Orders_Employees] ALTER TABLE [dbo].[orders] WITH CHECK ADD CONSTRAINT [FK_Orders_Products] FOREIGN KEY([OrdProductID]) REFERENCES [dbo].[products] ([ProductID]) ALTER TABLE [dbo].[orders] CHECK CONSTRAINT [FK_Orders_Products] ALTER TABLE [dbo].[orders] WITH CHECK ADD CONSTRAINT [FK_Orders_Shippers] FOREIGN KEY([OrdShipperID]) REFERENCES [dbo].[shippers] ([ShipperID]) ALTER TABLE [dbo].[orders] CHECK CONSTRAINT [FK_Orders_Shippers] Script 6 Products Table: USE [CCI] /****** Object: Table [dbo].[products] Script Date: 04/11/ :43:37 ******/ SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON
7 CS363: Structured Query Language for Data Management 7 SET ANSI_PADDING ON CREATE TABLE [dbo].[products]( [ProductID] [int] NOT NULL, [CatID] [int] NOT NULL, [ProSKUNumber] [varchar](10) NOT NULL, [ProName] [varchar](50) NOT NULL, [ProDescription] [text] NOT NULL, [ProCurrentQuantity] [int] NOT NULL, [ProStatus] [varchar](8) NOT NULL, [ProDateIntroduced] [date] NOT NULL, [ProCurrentSellingPrice] [money] NOT NULL, [ProMinimumQuantity] [int] NOT NULL, [ProMaximumQuantity] [int] NOT NULL, CONSTRAINT [PK_Products] PRIMARY KEY CLUSTERED ( [ProductID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] SET ANSI_PADDING OFF ALTER TABLE [dbo].[products] WITH CHECK ADD CONSTRAINT [FK_Products_Categories] FOREIGN KEY([CatID]) REFERENCES [dbo].[categories] ([CategoryID]) ALTER TABLE [dbo].[products] CHECK CONSTRAINT [FK_Products_Categories] ALTER TABLE [dbo].[products] WITH CHECK ADD CONSTRAINT [FK_Products_Products] FOREIGN KEY([ProductID]) REFERENCES [dbo].[products] ([ProductID]) ALTER TABLE [dbo].[products] CHECK CONSTRAINT [FK_Products_Products] Script 7 Shippers Table: USE [CCI] /****** Object: Table [dbo].[shippers] Script Date: 04/11/ :45:17 ******/ SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON SET ANSI_PADDING ON CREATE TABLE [dbo].[shippers]( [ShipperID] [int] IDENTITY(1,1) NOT NULL, [ShipperName] [varchar](50) NOT NULL, [ShipContactFirstName] [varchar](50) NOT NULL, [ShipContactLastName] [varchar](50) NOT NULL, [ShipperAddress] [varchar](50) NOT NULL, [ShipCity] [varchar](50) NOT NULL, [ShipState] [varchar](50) NOT NULL, [ShipPostalCode] [varchar](50) NOT NULL, [ShipCountry] [varchar](50) NOT NULL, [ShipPhoneNumber] [varchar](50) NOT NULL,
8 CS363: Structured Query Language for Data Management 8 [ShipContact Address] [varchar](50) NOT NULL, CONSTRAINT [PK_Shippers] PRIMARY KEY CLUSTERED ( [ShipperID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] SET ANSI_PADDING OFF Script 8 Vendors Table: USE [CCI] /****** Object: Table [dbo].[vendors] Script Date: 04/11/ :46:26 ******/ SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON SET ANSI_PADDING ON CREATE TABLE [dbo].[vendors]( [VendorID] [int] IDENTITY(1,1) NOT NULL, [VendorCompanyName] [varchar](50) NOT NULL, [VenPreferred] [varchar](3) NOT NULL, [VenContactName] [varchar](50) NOT NULL, [VenAddress] [varchar](300) NOT NULL, [VenPhoneNumber] [varchar](12) NOT NULL, [VenFaxNumber] [varchar](12) NULL, [Ven Address] [varchar](150) NOT NULL, [VenStatus] [varchar](8) NOT NULL, CONSTRAINT [PK_Vendors] PRIMARY KEY CLUSTERED ( [VendorID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] SET ANSI_PADDING OFF Script 9 Vendors_Products Table: USE [CCI] /****** Object: Table [dbo].[vendors_products] Script Date: 04/11/ :48:15 ******/ SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON CREATE TABLE [dbo].[vendors_products]( [LineItem] [int] IDENTITY(1,1) NOT NULL, [VenID] [int] NOT NULL, [ProID] [int] NOT NULL, CONSTRAINT [PK_Vendors_Products] PRIMARY KEY CLUSTERED ( [LineItem] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
9 CS363: Structured Query Language for Data Management 9 ) ON [PRIMARY] ALTER TABLE [dbo].[vendors_products] WITH CHECK ADD CONSTRAINT [FK_Vendors_Products_Products] FOREIGN KEY([ProID]) REFERENCES [dbo].[products] ([ProductID]) ALTER TABLE [dbo].[vendors_products] CHECK CONSTRAINT [FK_Vendors_Products_Products] ALTER TABLE [dbo].[vendors_products] WITH CHECK ADD CONSTRAINT [FK_Vendors_Products_Vendors] FOREIGN KEY([VenID]) REFERENCES [dbo].[vendors] ([VendorID]) ALTER TABLE [dbo].[vendors_products] CHECK CONSTRAINT [FK_Vendors_Products_Vendors] DCL STATEMENTS FOR LOGIN, USER, ROLES, AND PRIVILEGES (SECTION 1) COMPLETED BY: Darrell Moore Using your team's database, add the following: Section 1 Criteria: 1. DCL statements to create the login, user, role and assign the specified permissions for just the Clerk outlined in P2 DB. Don t forget to map the login to the user and assign the role to the user you create. Hint--use these steps: a. CREATE LOGIN to create the MySQL login b. CREATE USER to create the user, map the login to this user c. CREATE ROLE to create the role d. GRANT, DENY, REVOKE to assign permissions to that role e. assign role to user created in step b In order to meet the objective of this section Team Echo had to first create a login for the MS SQL Server. This login was named Clerk_1 with a password of password. Team Echo used the below script to create the aforementioned login. Script 1: CREATE LOGIN Clerk_1 WITH PASSWORD = 'password' To see the creation of this login Team Echo expanded the Security tab under the object viewer. This is a server level login. After creating this login Team Echo then created a user and assigned that user to the newly created login. To accomplish this Team Echo executed the following script. Script 2: USE CCI CREATE USER Clerk_1 FOR LOGIN Clerk_1
10 CS363: Structured Query Language for Data Management 10 This created a user by the name of Clerk_1 and assigned that user to the Clerk_1 login. From this point Team Echo then created a role to assign to the Clerk_1 user. To accomplish this Team Echo executed the following script. Script 3: USE CCI CREATE ROLE Clerks The above script created the role Clerks but that role was not assigned any users. To remedy this Team Echo executed the below stored procedure for adding a role member. Script 4: EXEC sp_addrolemember 'Clerks', Clerk_1 At this point Team Echo has so far created a login, a user, and a role. Now Team Echo must add permissions to the Clerk role as prescribed in the CS363 Phase 2 Discussion Board. If you recall that discussion board required that Clerks be granted SELECT privileges on the Inventory and the Vendor table. All other permissions are to be disallowed. Luckily this made the solution easier as newly created roles are automatically disallowed all privileges until you explicitly allow them. So all that was needed to accomplish the next step, was to perform a GRANT statement for selecting everything from the Vendor and Inventory tables. To accomplish this Team Echo executed the script below. Script 5: USE CCI GRANT SELECT ON OBJECT:: dbo.vendors TO Clerks Following the above command Team Echo performed the next command as listed below. Script 6: USE CCI GRANT SELECT ON OBJECT:: dbo.inventory TO Clerks For the purpose of continuity and cleanliness within the database Team Echo also added a Supervisor login, user, role, and privledges according to the criteria spelled out within Phase 2 Discussion Board. In order to build the Supervisor's login, user, role, and priveliges Team Echo had to accomplish the below scripts. The following scripts are the same as previously mentioned with alterations for the supervisor naming scheme and priveleges. Script 1: CREATE LOGIN Supervisor_1 WITH PASSWORD = 'password' Script 2: CREATE USER Supervisor_1 FOR LOGIN Supervisor_1 Script 3: USE CCI CREATE ROLE Supervisor
11 CS363: Structured Query Language for Data Management 11 Script 4: EXEC sp_addrolemember 'Supervisor', Supervisor_1 Script 5: USE CCI GRANT SELECT ON OBJECT:: dbo.vendors TO Supervisor Script 6: USE CCI GRANT SELECT ON OBJECT:: dbo.inventory TO Supervisor Script 7: USE CCI GRANT DELETE ON OBJECT:: dbo.inventory TO Supervisor Script 8: USE CCI GRANT INSERT ON OBJECT:: dbo.inventory TO Supervisor Script 9: USE CCI GRANT UPDATE ON OBJECT:: dbo.inventory TO Supervisor To test what Team Echo has accomplished, Team Echo connected to another server instance by clicking the connect button above the object viewer. From here Team Echo logged in as Client_1. The new connection only permits the team to view the Vendor and Inventory tables. The team cannot edit data within those tables however we can perform all necessary select statements. Following this the team then logged in as Supervisor_1. Logged in as Supervisor_1 we can view data in both the Vendor and Inventory tables. We can also add, edit, and delete information from the Inventory table but not the Vendor table. All of these parameters are within the prescribed construct of CS363 Phase 2 Discussion Board and CS363 Phase 4 Group Project. REPORT REQUEST QUERIES (SECTION 2) COMPLETED BY: Curtis Rice Section 2 Criteria: For this section of the CCI database design proposal our firm is illustrating the power of the constructed database. To best accomplish this, our firm has developed two specific queries that satisfy two different report requests (CS363, 2012). Report 1: Using the CCI database we generated a query to retrieve all rows of active inventory where the current on hand quantity is less than the prescribed minimum level. Knowing which products where within the threshold criteria of a reorder we then performed an aggregate function to between the current in stock quantity and the maximum allowable quantity to calculate the quantity of the reorder. In addition to this we named the field within the result set as "ReorderQuantity". Another step taken within this query was to include the Vendor information for the items that require a reorder purchase. This report query required the use of a LEFT OUTER JOIN to pull data from the Vendors table. You can see the scripted query below: Script 1:
12 CS363: Structured Query Language for Data Management 12 USE CCI SELECT Inventory.InvProductID, SUM (dbo.inventory.invmaximumlevel - dbo.inventory.invcurrentinstock)as ReorderQuantity, VendorCompanyName, VenAddress, VenPhoneNumber, VenContactName FROM Inventory LEFT OUTER JOIN Vendors ON dbo.inventory.invvendorid = dbo.vendors.vendorid WHERE InvCurrentInStock < InvMinimumLevel and InvDiscontinued = 0 GROUP BY Inventory.InvProductID,VendorCompanyName, VenAddress, VenPhoneNumber, VenContactName Report 2: The second report developed to demonstrate the power of this database had several variables to consider. In an effort to clarify what we accomplished Team Echo will enumerate those variables as follows. 1. The report must generate a number of vendors 2. Those vendors counted must not be preferred vendors 2. The vendor must also be a supplier of Category 2 products 3. The products must be active 4. The products must have been introduced on or after the year 2007 You can see the generated query script below: USE CCI SELECT COUNT(DISTINCT dbo.vendors.vendorid)as NumberOfNotPreferredCatID2VendorsOfActiveProductsIntroducedAfter2007 FROM dbo.vendors, dbo.inventory WHERE dbo.vendors.vendorid = dbo.inventory.invvendorid and dbo.vendors.venpreferred = 'Yes' and dbo.inventory.invcatid = 2 and dbo.inventory.invdiscontinued!= 'True' and dbo.inventory.invdateintroduced > = '2007' COMPLETED BY: Kanaan Pitts INDEXES AND SCRIPTS (SECTION 3) Section 3 Criteria: Within this section of the database design proposal our firm is illustrating the purpose and potential of indexes. As such we have provided a list of suggested indexes and the rationale behind those choices. It is our hope that we will illustrate the power that indexes can delivery when properly applied VARCHAR(MAX),
13 CS363: Structured Query Language for Data Management BIT -- used solely for putting information into the result table IF EXISTS (SELECT * FROM tempdb.dbo.sysobjects WHERE id = object_id(n'[tempdb].[dbo].[#indexsql]')) DROP TABLE [dbo].[#indexsql] CREATE TABLE #IndexSQL ( TableName VARCHAR(128) NOT NULL,IndexName VARCHAR(128) NOT NULL,IsClustered BIT NOT NULL,IsPrimaryKey BIT NOT NULL,IndexCreateSQL VARCHAR(max) NOT NULL ) IF EXISTS (SELECT * FROM tempdb.dbo.sysobjects WHERE id = object_id(n'[tempdb].[dbo].[#indexlisting]')) DROP TABLE [dbo].[#indexlisting] CREATE TABLE #IndexListing ( [IndexListingID] INT IDENTITY(1,1) PRIMARY KEY CLUSTERED, [TableName] SYSNAME COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [ObjectID] INT NOT NULL, [IndexName] SYSNAME COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [IndexID] INT NOT NULL, [IsPrimaryKey] TINYINT NOT NULL, [FillFactor] INT, [FilterDefinition] NVARCHAR(MAX) NULL ) IF EXISTS (SELECT * FROM tempdb.dbo.sysobjects WHERE id = object_id(n'[tempdb].[dbo].[#columnlisting]')) DROP TABLE [dbo].[#columnlisting] CREATE TABLE #ColumnListing ( [ColumnListingID] INT IDENTITY(1,1) PRIMARY KEY CLUSTERED, [ColumnIDInTable] INT NOT NULL, [Name] SYSNAME COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [ColumnIDInIndex] INT NOT NULL, [IsIncludedColumn] BIT NULL ) INSERT INTO #IndexListing( [TableName], [ObjectID], [IndexName], [IndexID], [IsPrimaryKey], [FILLFACTOR], [FilterDefinition] ) SELECT OBJECT_NAME(si.object_id), si.object_id, si.name, si.index_id, si.is_primary_key, si.fill_factor, si.filter_definition FROM sys.indexes si LEFT OUTER JOIN information_schema.table_constraints tc ON si.name = tc.constraint_name AND OBJECT_NAME(si.object_id) = tc.table_name WHERE OBJECTPROPERTY(si.object_id, 'IsUserTable') = 1 ORDER BY OBJECT_NAME(si.object_id), si.index_id = = 1
14 CS363: Structured Query Language for Data Management 14 = = = = = = = [FilterDefinition] FROM #IndexListing WHERE [IndexListingID] -- So - it is either an index or a constraint -- Check if the index is unique IF (@IsPrimaryKey = 1) = 'ALTER TABLE [dbo].[' + '] ADD CONSTRAINT [' + '] PRIMARY KEY ' -- Check if the index is clustered IF 'IsClustered') = 0) + 'NON' = 0 ELSE = 1 + 'CLUSTERED' + CHAR(13) + '(' + CHAR(13) ELSE = 'CREATE ' -- Check if the index is unique IF 'IsUnique') = 1) + 'UNIQUE ' -- Check if the index is clustered IF 'IsClustered') = 1) + 'CLUSTERED ' = 1 ELSE = 0 + 'INDEX [' + '] ON [dbo].[' + ']' + CHAR(13) + '(' + = 0 -- Get the number of cols in the index = COUNT(*) FROM sys.index_columns ic INNER JOIN sys.columns sc ON ic.object_id = sc.object_id AND ic.column_id = sc.column_id WHERE ic.object_id AND index_id AND ic.is_included_column = 0
15 CS363: Structured Query Language for Data Management Get the file group info = f.[name] FROM sys.indexes i INNER JOIN sys.filegroups f ON i.data_space_id = f.data_space_id INNER JOIN sys.all_objects o ON i.[object_id] = o.[object_id] WHERE o.object_id AND i.index_id -- Get all columns of the index INSERT INTO #ColumnListing( [ColumnIDInTable], [Name], [ColumnIDInIndex],[IsIncludedColumn] ) SELECT sc.column_id, sc.name, ic.index_column_id, ic.is_included_column FROM sys.index_columns ic INNER JOIN sys.columns sc ON ic.object_id = sc.object_id AND ic.column_id = sc.column_id WHERE ic.object_id AND index_id ORDER BY ic.index_column_id > 0 = 1 = = = '' = = = = IsIncludedColumn FROM #ColumnListing WHERE [ColumnListingID] = 0 = CHAR(9) + '[' + '] ' -- Check the sort order of the index cols???????? IF (INDEXKEY_PROPERTY (@idxtableid,@idxid,@columnidinindex,'isdescending')) = 0 + ' ASC ' ELSE + ' DESC ' + ', ' ELSE -- Check for any include columns IF LEN(@sIncludeCols) > 0 + ',' + '[' + ']' + 1 TRUNCATE TABLE #ColumnListing --append to the result IF LEN(@sIncludeCols) > 0
16 CS363: Structured Query Language for Data Management CHAR(13) + ') ' + ' INCLUDE ( ' + ' ) ' ELSE + CHAR(13) + ') ' -- Add filtering IS NOT NULL = ' WHERE ' + ' ' + CHAR(13) ELSE = '' -- Build the options = 'WITH ( PAD_INDEX = ' IF 'IsPadIndex') = 1 + 'ON,' ELSE + 'OFF,' + ' ALLOW_PAGE_LOCKS = ' IF 'IsPageLockDisallowed') = 0 + 'ON,' ELSE + 'OFF,' + ' ALLOW_ROW_LOCKS = ' IF 'IsRowLockDisallowed') = 0 + 'ON,' ELSE + 'OFF,' + ' STATISTICS_NORECOMPUTE = ' -- THIS DOES NOT WORK PROPERLY; IsStatistics only says what generated the last set, not what it was set to do. IF 'IsStatistics') = 1) + 'ON' ELSE + 'OFF' -- Fillfactor 0 is actually not a valid percentage on SQL 2008 R2 IF 90 ) <> 0 + ',FILLFACTOR = ' + CAST( 90 ) AS VARCHAR(3) ) IF (@IsPrimaryKey = 1) -- DROP_EXISTING isn't valid for PK's + ' ) ' ELSE + ',DROP_EXISTING = ON ) ' + CHAR(13) + CHAR(13) R2 allows ON [filegroup] for primary keys as well, negating the old "IF THE INDEX IS NOT A PRIMARY KEY - ADD THIS - ELSE DO NOT" IsPrimaryKey IF statement + ' ON [' + ']' + CHAR(13) INSERT INTO #IndexSQL (TableName, IndexName, IsClustered, IsPrimaryKey, IndexCreateSQL) SELECT * FROM #IndexSQL
17 CS363: Structured Query Language for Data Management 17 STORED PROCEDURE (SECTION 4) COMPLETED BY: Trina VanderLouw Section 4 Criteria: A Stored Procedure that does the following: it accepts three parameters called Category, InventoryLevel and IntroDate. The output should list all Inventories where the current quantity is below the specified InventoryLevel for the specified Category. It should exclude any Inventories that are time stamped prior to the supplied IntroDate parameter. Name the stored procedure appropriately and provide the script to create it. Also, supply the script to call this new stored procedure passing it parameter values of your choice (CS363, 2012). Stored Procedure for CCI STORED PROCEDURE LowInventory USE [CCI] /****** Object: StoredProcedure [dbo].[lowinventory] Script Date: 04/13/ :24:50 ******/ SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON -- ========================================================= -- Author: Trina VanderLouw -- Create date: April 13, CS363: SQL for Data Management; Group Project: Team E -- Description: Returns list of all inventories where the -- current inventory is below the specified InventoryLevel -- for the specified Category. List Excludes any inventories -- that are time stamped prior to the supplied IntroDate. -- ========================================================== CREATE PROCEDURE [dbo].[lowinventory] -- Parameters for the stored int = int = date AS -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Statements to return low inventory list SELECT CCI.dbo.Products.ProName FROM CCI.dbo.Products LEFT OUTER JOIN CCI.dbo.Inventory ON Products.ProductID = Inventory.InvProductID WHERE Inventory.InvCurrentInStock AND Inventory.InvCatID AND NOT Inventory.InvDateIntroduced CALL TO EXECUTE STORED PROCEDURE
18 CS363: Structured Query Language for Data Management 18 USE [CCI] EXEC LowInventory 1, 50, ' ' To test the query: Team Echo passed in category 1, less than 50 for inventory level, and not prior to This was the product list returned. (Team Echo added a few more products to try out the query with different parameters.) Second test: Team Echo changed the date to a later date and only one product was returned. USE [CCI] EXEC LowInventory 1, 100, ' '
19 CS363: Structured Query Language for Data Management 19 CONCLUSION COMPLETED BY: Darrell Moore In closing, we are awaiting Canine Caper's Inc (CCI) acceptance of this database design proposal. The necessary tools to deploy this design have been included within this proposal. Upon deployment of the CCI database we will remove all test data and user accounts. At that time new user accounts will be created prior to the addition of legitimate data. In recap this proposal contains the necessary CCI database ERD, the scripts necessary to build the CCI database, the scripts necessary to build CCI's users, roles, logins, and privileges, example report queries, functional indexes and scripts, and necessary stored procedures (CS363, 2012). REFERENCES CS363. (2012, February 21). Colorado Technical University Online CS363 Task Listing. Retrieved February 21, 2012, from Colorado Technical University Online Virtual Campus:
20 CS363: Structured Query Language for Data Management 20 SQL Statements Trina VanderLouw Colorado Technical University
21 CS363: Structured Query Language for Data Management 21 Northwind SQL Statements This assignment requires statements to check the modifications to the database from Phase 3 IP 1. Each of the queries returned the desired results. 1. Using the Northwind database, write a script to insert the following data: One new Category Name = Junk Food, Description = yummy delights SELECT * FROM Northwind.dbo.Categories WHERE CategoryName = 'Junk Food' This query returned one new category called Junk Food with a description of yummy delights. 2. Add a Product for your new Junk Food category. Product = Twinkies, Supplier = Tokyo Traders, Category = Junk Food QuantityPerUnit = 10 boxes UnitsInStock = 0, UnitsOnOrder = 0, ReorderLevel = 10, Disabled = 0 SELECT * FROM Northwind.dbo.Products WHERE ProductName = 'Twinkies' This query returned one product entry for Twinkies with all the correct values set. 3. In an attempt to liquidate some Products, in the Northwind database, provide a script to set all Products in the Condiments category that have less than 20 units in stock to a price of $5.00 and disable them. HINT: four records should be affected SELECT * FROM Northwind.dbo.Products WHERE CategoryID=2 AND UnitsInStock<20 This query showed me the four products that were changed and that they were all set to $5.00 and Discontinued. 4. Your boss has decided against the new Junk Food Category. Provide a script to delete the Junk Food Category as well as any Products assigned to that category. SELECT * FROM Northwind.dbo.Products WHERE CategoryName = 'Junk Food' SELECT * FROM Northwind.dbo.Categories WHERE CategoryName = 'Junk Food' Both queries returned 0 results.
22 CS363: Structured Query Language for Data Management Using the Northwind database, write a script to insert the following data: One new Category Name = Junk Food, Description = yummy delights INSERT INTO Northwind.dbo.Categories (CategoryName, Description) VALUES ('Junk Food', 'yummy delights') 6. Add a Product for your new Junk Food category. Product = Twinkies, Supplier = Tokyo Traders, Category = Junk Food QuantityPerUnit = 10 boxes UnitsInStock = 0, UnitsOnOrder = 0, ReorderLevel = 10, Disabled = 0 For this query I had to lookup the SupplierID and CategoryID. These were found using: SELECT * FROM Northwind.dbo.Categories WHERE CategoryName='Junk Food' This told me the CategoryID was 9. SELECT * FROM Northwind.dbo.Suppliers WHERE CategoryName= Tokyo Traders This told me the SupplierID was 4. Then I wrote the query to add the Twinkies. INSERT INTO Northwind.dbo.Products (ProductName, SupplierID, CategoryID, QuantityPerUnit,UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued) VALUES ('Twinkies', 4, 9, 10, 0, 0, 10, 0) 7. In an attempt to liquidate some Products, in the Northwind database, provide a script to set all Products in the Condiments category that have less than 20 units in stock to a price of $5.00 and disable them. HINT: four records should be affected For this update I looked up the condiments CategoryID. SELECT * FROM Northwind.dbo.Categories WHERE CategoryName='Condiments' This told me the CategoryID was 2. The next query I ran was an update to set the price to $5.00 and discontinued for the products that are in category 2 and have less than 20 in stock. It changed four products. UPDATE Northwind.dbo.Products SET UnitPrice=5, Discontinued=0 WHERE CategoryID=2 AND UnitsInStock<20
23 CS363: Structured Query Language for Data Management Your boss has decided against the new Junk Food Category. Provide a script to delete the Junk Food Category as well as any Products assigned to that category. For this query I chose to delete all the products in category 9 (Junk Food) and then to delete the Category Junk Food. DELETE FROM Northwind.dbo.Products WHERE CategoryID=9 DELETE FROM Northwind.dbo.Categories WHERE CategoryName='Junk Food' Northwind Customer s Report 1. For a Customers report, show the Company, Contact name, their title, the CustomerId, Country and Region (in that order). Rename the Region column in your output as RegionOrState. Sort by Country, then Region. USE Northwind SELECT CompanyName, ContactName, ContactTitle, CustomerID, Country, Region AS "RegionOrState" FROM Customers ORDER BY Country, Region; 2. Provide a unique list of the Countries where we have Customers USE Northwind SELECT DISTINCT Country FROM Customers; 3. A list of all Customers that don't have a Fax number USE Northwind SELECT CompanyName FROM Customers WHERE Fax IS NULL; 4. An Ordering Clerk comes to you with the Company name of a supplier and needs the SupplierId. The Company is Mayumi's. Write a query to provide the SupplierId. USE Northwind SELECT SupplierID, CompanyName FROM Suppliers WHERE CompanyName LIKE 'Mayumi%s'; 5. A list of all discontinued products in Category 1 and 6. **** I ordered by category and then alphabetically even though it was not required****
24 CS363: Structured Query Language for Data Management 24 USE Northwind SELECT ProductName FROM Products WHERE Discontinued = '1' AND (CategoryID = '1' OR CategoryID = '6') ORDER BY CategoryID, ProductName 6. A list of all Orders that contains the OrderId, OrderDate and name of the Company that placed the Order, sorted by most recent date USE Northwind SELECT OrderID, OrderDate, CompanyName FROM Orders, Customers WHERE Orders.CustomerID = Customers.CustomerID ORDER BY OrderDate; 7. Provide a list of all orders that includes the OrderId, the employee s name that helped with that order and the name of the company that placed the order. The list should also have the country of the shipping address. Sort it alphabetically by employee name, then country. The list should include only those orders shipped outside of the USA USE Northwind SELECT OrderID, FirstName, LastName, CompanyName, Customers.Country FROM Orders, Employees, Customers WHERE Customers.Country NOT LIKE 'USA' ORDER BY FirstName, LastName, Customers.Country 8. Number of Orders placed in the month of April of 1997 USE Northwind SELECT COUNT(OrderID) AS 'TotalOrders' FROM Orders WHERE OrderDate BETWEEN ' ' AND ' '; 9. What is the total number of Customers in each country? Name the count column CountryCount and sort in order of most to least. USE Northwind SELECT Country, COUNT(CustomerID) as 'CountryCount' FROM Customers GROUP BY Country ORDER BY CountryCount desc 10. List all Customers (include CustomerId and CompanyName) that have placed less than orders. Include those who have zero orders placed. Name the count field "OrderCount". Sort by least number of orders placed.
25 CS363: Structured Query Language for Data Management 25 USE Northwind SELECT Customers.CustomerID, Customers.CompanyName, COUNT(OrderID) as 'OrderCount' FROM Customers LEFT OUTER JOIN Orders ON Customers.CustomerID = Orders.CustomerID GROUP BY Customers.CustomerID, Customers.CompanyName HAVING COUNT(OrderID) <= 3 ORDER BY OrderCount
26 CS363: Structured Query Language for Data Management 26
ISM 4212/4480 Milestone V Submission Sample
This document shows an example of what the entire turn-in documentation for a single team member s portion of Milestone V might look like. It uses the NorthWinds Traders database. Joe Smith Transaction:
More informationNorthwind Database. Sample Output from TechWriter 2007 for Databases
Table of Contents Northwind Database...3 Tables... 4 Categories...5 CustomerCustomerDemo... 6 CustomerDemographics... 7 Customers... 8 Employees...9 EmployeeTerritories... 11 Order Details... 12 Orders...
More informationChapter 3. Introduction to relational databases and MySQL. 2010, Mike Murach & Associates, Inc. Murach's PHP and MySQL, C3
1 Chapter 3 Introduction to relational databases and MySQL Slide 2 Objectives Applied 1. Use phpmyadmin to review the data and structure of the tables in a database, to import and run SQL scripts that
More informationSolutions to the Problems in SQL Practice Problems by Sylvia Moestl Vasilik. John Weatherwax
Solutions to the Problems in SQL Practice Problems by Sylvia Moestl Vasilik John Weatherwax 1 Text copyright c 2018 John L. Weatherwax All Rights Reserved Please Do Not Redistribute Without Permission
More informationIntroduction to SQL. IT 5101 Introduction to Database Systems. J.G. Zheng Fall 2011
Introduction to SQL IT 5101 Introduction to Database Systems J.G. Zheng Fall 2011 Overview Using Structured Query Language (SQL) to get the data you want from relational databases Learning basic syntax
More informationIntroduction to relational databases and MySQL
Chapter 3 Introduction to relational databases and MySQL A products table Columns 2017, Mike Murach & Associates, Inc. C3, Slide 1 2017, Mike Murach & Associates, Inc. C3, Slide 4 Objectives Applied 1.
More informationChris Singleton 03/12/2017 PROG 140 Transactions & Performance. Module 8 Assignment
Chris Singleton 03/12/2017 PROG 140 Transactions & Performance Module 8 Assignment Turn In: For this exercise, you will submit one WORD documents (instead of a.sql file) in which you have copied and pasted
More informationHow to use SQL to create a database
Chapter 17 How to use SQL to create a database How to create a database CREATE DATABASE my_guitar_shop2; How to create a database only if it does not exist CREATE DATABASE IF NOT EXISTS my_guitar_shop2;
More informationAssignment Grading Rubric
Final Project Outcomes addressed in this activity: Overview and Directions: 1. Create a new Empty Database called Final 2. CREATE TABLES The create table statements should work without errors, have the
More informationProject 7: Northwind Traders Order Entry
Project 7: Northwind Traders Order Entry 1 Northwinds Order Entry Extend the Select Customer program from Project 6 to permit the user to enter orders. Add orders to the database. Print invoices. Refer
More informationViews in SQL Server 2000
Views in SQL Server 2000 By: Kristofer Gafvert Copyright 2003 Kristofer Gafvert 1 Copyright Information Copyright 2003 Kristofer Gafvert (kgafvert@ilopia.com). No part of this publication may be transmitted,
More informationModule 5: Implementing Data Integrity
Module 5: Implementing Data Integrity Overview Types of Data Integrity Enforcing Data Integrity Defining Constraints Types of Constraints Disabling Constraints Using Defaults and Rules Deciding Which Enforcement
More informationCourse Topics. Microsoft SQL Server. Dr. Shohreh Ajoudanian. 01 Installing MSSQL Server Data types
Dr. Shohreh Ajoudanian Course Topics Microsoft SQL Server 01 Installing MSSQL Server 2008 03 Creating a database 05 Querying Tables with SELECT 07 Using Set Operators 02 Data types 04 Creating a table,
More informationHow to use SQL to work with a MySQL database
Chapter 18 How to use SQL to work with a MySQL database Objectives (continued) Knowledge 7. Describe the use of the GROUP BY and HAVING clauses in a SELECT statement, and distinguish between HAVING clauses
More informationMore on MS Access queries
More on MS Access queries BSAD 141 Dave Novak Topics Covered MS Access query capabilities Aggregate queries Different joins Review: AND and OR Parameter query Exact match criteria versus range Formatting
More informationAppendix A. Using DML to Modify Data. Contents: Lesson 1: Adding Data to Tables A-3. Lesson 2: Modifying and Removing Data A-8
A-1 Appendix A Using DML to Modify Data Contents: Lesson 1: Adding Data to Tables A-3 Lesson 2: Modifying and Removing Data A-8 Lesson 3: Generating Numbers A-15 A-2 Using DML to Modify Data Module Overview
More informationCLARITY WRITE BACK CONFIGURATION White Paper
CLARITY WRITE BACK CONFIGURATION White Paper Clarity 7 White Paper: Write-Back Configuration Version 7.0 2nd Edition Microsoft is a registered trademark. Microsoft SQL Server, Office, Excel, Word, Internet
More informationChapter 3 Introduction to relational databases and MySQL
Chapter 3 Introduction to relational databases and MySQL Murach's PHP and MySQL, C3 2014, Mike Murach & Associates, Inc. Slide 1 Objectives Applied 1. Use phpmyadmin to review the data and structure of
More informationStructured Query Language (SQL)
Structured Query Language (SQL) SQL Chapters 6 & 7 (7 th edition) Chapters 4 & 5 (6 th edition) PostgreSQL on acsmysql1.acs.uwinnipeg.ca Each student has a userid and initial password acs!
More informationKillTest. 半年免费更新服务
KillTest 质量更高 服务更好 学习资料 http://www.killtest.cn 半年免费更新服务 Exam : 70-442GB2312 Title : PRO:Design & Optimize Data Access by Using MS SQL Serv 2005 Version : Demo 1 / 19 1. OrderItems OrderItems OrderID (PK,
More information1.2 - The Effect of Indexes on Queries and Insertions
Department of Computer Science and Engineering Data Administration in Information Systems Lab 2 In this lab class, we will approach the following topics: 1. Important Concepts 1. Clustered and Non-Clustered
More informationModule 4: Creating and Tuning Indexes
Module 4: Creating and Tuning Indexes Overview Planning Indexes Creating Indexes Optimizing Indexes 1 Lesson 1: Planning Indexes How SQL Server Accesses Data What Is a Clustered Index? What Is a Heap?
More informationRelational Database Development
Instructor s Relational Database Development Views, Indexes & Security Relational Database Development 152-156 Views, Indexes & Security Quick Links & Text References View Description Pages 182 183 187
More informationGeorge Cantor, in Georg Cantor by Joseph W. Dauben (Princeton University Press, 1990) P: X {true, false} Each phase operates on one or more tables as inputs and returns a virtual table as output. The
More informationL e a r n S q l select where
L e a r n S q l The select statement is used to query the database and retrieve selected data that match the criteria that you specify. Here is the format of a simple select statement: select "column1"
More informationEXAM TS: Microsoft SQL Server 2008, Database Development. Buy Full Product.
Microsoft EXAM - 70-433 TS: Microsoft SQL Server 2008, Database Development Buy Full Product http://www.examskey.com/70-433.html Examskey Microsoft 70-433 exam demo product is here for you to test the
More informationExam code: Exam name: Database Fundamentals. Version 16.0
98-364 Number: 98-364 Passing Score: 800 Time Limit: 120 min File Version: 16.0 Exam code: 98-364 Exam name: Database Fundamentals Version 16.0 98-364 QUESTION 1 You have a table that contains the following
More informationIT Certification Exams Provider! Weofferfreeupdateserviceforoneyear! h ps://www.certqueen.com
IT Certification Exams Provider! Weofferfreeupdateserviceforoneyear! h ps://www.certqueen.com Exam : 70-457 Title : Transition Your MCTS on SQL Server 2008 to MCSA: SQL Server 2012, Part 1 Version : Demo
More informationActivant Solutions Inc. SQL 2005: Basic Data Manipulation
Activant Solutions Inc. SQL 2005: Basic Data Manipulation SQL Server 2005 suite Course 4 of 4 This class is designed for Beginner/Intermediate SQL Server 2005 System Administrators Objectives System Stored
More informationSubmit the MS Access Database file that contains the forms created in this lab.
A. Lab # : BSBA BIS245A-5B B. Lab 5B of 7: Completing Forms C. Lab Overview--Scenario/Summary TCO(s): 5. Given a physical database containing tables and relationships, create forms which demonstrate effective
More informationPreviously everyone in the class used the mysql account: Username: csci340user Password: csci340pass
Database Design, CSCI 340, Spring 2016 SQL, Transactions, April 15 Previously everyone in the class used the mysql account: Username: csci340user Password: csci340pass Personal mysql accounts have been
More information1Z Oracle Database 11g - SQL Fundamentals I Exam Summary Syllabus Questions
1Z0-051 Oracle Database 11g - SQL Fundamentals I Exam Summary Syllabus Questions Table of Contents Introduction to 1Z0-051 Exam on Oracle Database 11g - SQL Fundamentals I 2 Oracle 1Z0-051 Certification
More informationInstructor: Craig Duckett. Lecture 14: Tuesday, May 15 th, 2018 Stored Procedures (SQL Server) and MySQL
Instructor: Craig Duckett Lecture 14: Tuesday, May 15 th, 2018 Stored Procedures (SQL Server) and MySQL 1 Assignment 3 is due LECTURE 20, Tuesday, June 5 th Database Presentation is due LECTURE 20, Tuesday,
More informationProfessional Edition Tutorial: Basic Excel
Professional Edition Tutorial: Basic Excel Pronto, Visualizer, and Dashboards 2.0 Documentation Release 3/29/2017 i Copyright 2015-2017 Birst, Inc. Copyright 2015-2017 Birst, Inc. All rights reserved.
More informationDeploying the ClientDashboard Web Site
Deploying the ClientDashboard Web Site June 2013 Contents Introduction... 2 Installing and configuring IIS... 2 Software installations... 2 Opening a firewall port... 2 Adding the SCSWebDashboard Web site...
More informationTestpassport. Банк экзамен
Testpassport Банк экзамен самое хорошое качество самая хорошая служба Exam : 70-433 Title : TS: Microsoft SQL Server 2008, Database Development Version : DEMO 1 / 8 1.You have a user named John. He has
More informationSCHOOL OF COMPUTING HND YEAR 2 SOFTWARE DEVELOPMENT. Databases and SQL ICA. Paul Nicks (f )
SCHOOL OF COMPUTING HND YEAR 2 SOFTWARE DEVELOPMENT Databases and SQL ICA Paul Nicks (f6106647) January 2008 CONTENTS 1 INTRODUCTION.. 5 1.1 Overview 5 1.2 Identified Constraints 5 1.3 Deliverables 5 2
More informationPronto User Guide. Birst Software Version Document Release Wednesday, November 01, Copyright Birst, Inc.
Pronto User Guide Birst Software Version 5.28.6 Document Release Wednesday, November 01, 2017 i Copyright 2015-2017 Birst, Inc. Copyright 2015-2017 Birst, Inc. All rights reserved. Birst and its logo are
More informationModule 11: Implementing Triggers
Module 11: Implementing Triggers Overview Introduction Defining Create, drop, alter triggers How Triggers Work Examples Performance Considerations Analyze performance issues related to triggers Introduction
More informationEbook : Overview of application development. All code from the application series books listed at:
Ebook : Overview of application development. All code from the application series books listed at: http://www.vkinfotek.com with permission. Publishers: VK Publishers Established: 2001 Type of books: Develop
More informationStructured Query Language (SQL): A Primer on Data Definition Language (DDL)
(SQL): A Primer on Data Definition Language (DDL) Konana, 2000 Prabhudev Konana, Ph.D. Assistant Professor The Graduate School of Business The University of Texas at Austin Austin, TX 78712 Introduction
More informationTechnical Manual. Lesotho Health Data Warehouse. Prepared by: Gareth Daniell. Prepared for:
Technical Manual Lesotho Health Data Warehouse Prepared by: Gareth Daniell Prepared for: The Lesotho Department of Health Planning and Statistics, Lesotho Bureau of Statistics and the World Bank, General
More informationMICROSOFT EXAM QUESTIONS & ANSWERS
MICROSOFT 70-461 EXAM QUESTIONS & ANSWERS Number: 70-461 Passing Score: 700 Time Limit: 300 min File Version: 36.2 http://www.gratisexam.com/ MICROSOFT 70-461 EXAM QUESTIONS & ANSWERS Exam Name: Querying
More informationUse Schema_id Sql Server Schema Id Sys Tables
Use Schema_id Sql Server Schema Id Sys Tables schema_id) = s. The column principal_id in sys.schemas contains the ID of the schema owner, so to get the name you can Use the column principal_id in sys.tables,
More informationColumnStore Indexes UNIQUE and NOT DULL
Agenda ColumnStore Indexes About me The Basics Key Characteristics DEMO SQL Server 2014 ColumnStore indexes DEMO Best Practices Data Types Restrictions SQL Server 2016+ ColumnStore indexes Gareth Swanepoel
More informationT-sql Check If Index Exists Information_schema
T-sql Check If Index Exists Information_schema Is there another way to check if table/column exists in SQL Server? indexes won't pick them up, causing it to use the Clustered Index whenever a new column
More information/* --6). Name: Christopher Singleton Date: 02/12/2017 Class: PROG 140 Project: Module 04
/* --6. Name: Christopher Singleton Date: 02/12/2017 Class: PROG 140 Project: Module 04 About this Original Script: Drops Database IF EXISTS / Creates Database / Inserts three rows into three tables with
More informationSQL Server 2012 Development Course
SQL Server 2012 Development Course Exam: 1 Lecturer: Amirreza Keshavarz May 2015 1- You are a database developer and you have many years experience in database development. Now you are employed in a company
More informationSmart Database [Stored Procedures - Functions Trigger]
Smart Database [Stored Procedures - Functions Trigger] Stored Procedures A stored procedure is an already written SQL statement that is saved in the database. Benefits of Stored Procedures: 1. Precompiled
More informationSQL Server Integration Services
ETL Development with SQL Server Integration Services Overview This purpose of this lab is to give you a clear picture of how ETL development is done using an actual ETL tool. The tool we will use is called
More informationHOW TO CREATE AND MAINTAIN DATABASES AND TABLES. By S. Sabraz Nawaz Senior Lecturer in MIT FMC, SEUSL
HOW TO CREATE AND MAINTAIN DATABASES AND TABLES By S. Sabraz Nawaz Senior Lecturer in MIT FMC, SEUSL What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate
More informationINTERMEDIATE SQL GOING BEYOND THE SELECT. Created by Brian Duffey
INTERMEDIATE SQL GOING BEYOND THE SELECT Created by Brian Duffey WHO I AM Brian Duffey 3 years consultant at michaels, ross, and cole 9+ years SQL user What have I used SQL for? ROADMAP Introduction 1.
More informationStat Wk 3. Stat 342 Notes. Week 3, Page 1 / 71
Stat 342 - Wk 3 What is SQL Proc SQL 'Select' command and 'from' clause 'group by' clause 'order by' clause 'where' clause 'create table' command 'inner join' (as time permits) Stat 342 Notes. Week 3,
More informationMySQL. Prof.Sushila Aghav
MySQL Prof.Sushila Aghav Introduction SQL is a standard language for storing, manipulating and retrieving data in databases. SQL is a part of many relational database management systems like: MySQL, SQL
More informationInstructor: Craig Duckett. Lecture 11: Thursday, May 3 th, Set Operations, Subqueries, Views
Instructor: Craig Duckett Lecture 11: Thursday, May 3 th, 2018 Set Operations, Subqueries, Views 1 MID-TERM EXAM GRADED! Assignment 2 is due LECTURE 12, NEXT Tuesday, May 8 th in StudentTracker by MIDNIGHT
More informationMASSACHUSETTS INSTITUTE OF TECHNOLOGY Sloan School of Management
MASSACHUSETTS INSTITUTE OF TECHNOLOGY Sloan School of Management 15.561 IT Essentials Spring 2005 An Introduction to Microsoft Access * Lecture Script 1. Introduction Open Database: Northwind.mdb Select
More informationIMPORTING DATA IN PYTHON I. Introduction to relational databases
IMPORTING DATA IN PYTHON I Introduction to relational databases What is a relational database? Based on relational model of data First described by Edgar Ted Codd Example: Northwind database Orders table
More informationAssignment 6: SQL III Solution
Data Modelling and Databases Exercise dates: April 12/April 13, 2018 Ce Zhang, Gustavo Alonso Last update: April 16, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 6: SQL III Solution This assignment
More informationInstructor: Craig Duckett. Lecture 03: Tuesday, April 3, 2018 SQL Sorting, Aggregates and Joining Tables
Instructor: Craig Duckett Lecture 03: Tuesday, April 3, 2018 SQL Sorting, Aggregates and Joining Tables 1 Assignment 1 is due LECTURE 5, Tuesday, April 10 th, 2018 in StudentTracker by MIDNIGHT MID-TERM
More informationReceiver Storefront 1.0
Receiver Storefront 1.0 2013-08-11 04:36:47 UTC 2013 Citrix Systems, Inc. All rights reserved. Terms of Use Trademarks Privacy Statement Contents Receiver Storefront 1.0... 4 About This Release... 5 Known
More informationProfessional Edition Tutorial: Excel Spreadsheets
-- DRAFT DOCUMENTATION RELEASE-- Information Subject to Change Professional Edition Tutorial: Excel Spreadsheets Pronto, Visualizer, and Dashboards 2.0 Documentation Release 3/7/2017 i Copyright 2015-2017
More informationJarek Szlichta
Jarek Szlichta http://data.science.uoit.ca/ SQL is a standard language for accessing and manipulating databases What is SQL? SQL stands for Structured Query Language SQL lets you gain access and control
More informationSQL Server Administration Class 4 of 4. Activant Prophet 21. Basic Data Manipulation
SQL Server Administration Class 4 of 4 Activant Prophet 21 Basic Data Manipulation This class is designed for Beginner SQL/Prophet21 users who are responsible for SQL Administration as it relates to Prophet
More informationExact Numeric Data Types
SQL Server Notes for FYP SQL data type is an attribute that specifies type of data of any object. Each column, variable and expression has related data type in SQL. You would use these data types while
More informationExam Name: Querying Microsoft SQL Server 2012
Vendor:Microsoft Exam Code: 70-461 Exam Name: Querying Microsoft SQL Server 2012 Version: Demo QUESTION 1 You administer a Microsoft SQL Server 2012 database named ContosoDB. Tables are defined as shown
More informationPreviously everyone in the class used the mysql account: Username: csci340user Password: csci340pass
Database Design, CSCI 340, Spring 2016 SQL, Transactions, April 15 Previously everyone in the class used the mysql account: Username: csci340user Password: csci340pass Personal mysql accounts have been
More informationKeys are fields in a table which participate in below activities in RDBMS systems:
Keys are fields in a table which participate in below activities in RDBMS systems: 1. To create relationships between two tables. 2. To maintain uniqueness in a table. 3. To keep consistent and valid data
More informationAccess Objects. Tables Queries Forms Reports Relationships
Access Review Access Objects Tables Queries Forms Reports Relationships How Access Saves a Database The Save button in Access differs from the Save button in other Windows programs such as Word and Excel.
More informationGETTING STARTED WITH CODE ON TIME Got data? Generate modern web apps in minutes. Learn to create sophisticated web apps with Code On Time application
2012 GETTING STARTED WITH CODE ON TIME Got data? Generate modern web apps in minutes. Learn to create sophisticated web apps with Code On Time application generator for ASP.NET, Azure, DotNetNuke, and
More informationUnit 1 - Chapter 4,5
Unit 1 - Chapter 4,5 CREATE DATABASE DatabaseName; SHOW DATABASES; USE DatabaseName; DROP DATABASE DatabaseName; CREATE TABLE table_name( column1 datatype, column2 datatype, column3 datatype,... columnn
More informationGridDB Advanced Edition SQL reference
GMA022C1 GridDB Advanced Edition SQL reference Toshiba Solutions Corporation 2016 All Rights Reserved. Introduction This manual describes how to write a SQL command in the GridDB Advanced Edition. Please
More informationCOPYRIGHTED MATERIAL. Chapter. Database Logical Modeling MICROSOFT EXAM OBJECTIVES COVERED IN THIS CHAPTER:
Chapter 1 Database Logical Modeling MICROSOFT EXAM OBJECTIVES COVERED IN THIS CHAPTER: Define entities. Considerations include entity composition and normalization. Specify entity attributes. Specify degree
More informationStored Procedures and Functions. Rose-Hulman Institute of Technology Curt Clifton
Stored Procedures and Functions Rose-Hulman Institute of Technology Curt Clifton Outline Stored Procedures or Sprocs Functions Statements Reference Defining Stored Procedures Named Collections of Transact-SQL
More informationSQL Commands & Mongo DB New Syllabus
Chapter 15 : Computer Science Class XI ( As per CBSE Board) SQL Commands & Mongo DB New Syllabus 2018-19 SQL SQL is an acronym of Structured Query Language.It is a standard language developed and used
More informationDatabase Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL)
Database Systems: Design, Implementation, and Management Tenth Edition Chapter 7 Introduction to Structured Query Language (SQL) Objectives In this chapter, students will learn: The basic commands and
More informationPassReview. PassReview - IT Certification Exams Pass Review
PassReview http://www.passreview.com PassReview - IT Certification Exams Pass Review Exam : 70-761 Title : Querying Data with Transact- SQL Vendor : Microsoft Version : DEMO Get Latest & Valid 70-761 Exam's
More informationSQL Best Practices. Chandra Sekhar
SQL Best Practices Chandra Sekhar Agenda Application failing with "String too large error" My application is not running fast enough Push your application logic to User Defined Functions Use Scalar Subquery
More informationFIGURE 2.57 Denver Rooms 3 Guests Query. '3 LocationlD C", Address. Orders. Service. ServlceNlIme PerPersonCharge
The Prestige Hotel chain caters to upscale business travelers and provides state-of-the-art conference, meeting} and reception facilities. It prides itself on its international. four-star cuisine. Last
More informationMicrosoft Exam Querying Microsoft SQL Server 2012 Version: 13.0 [ Total Questions: 153 ]
s@lm@n Microsoft Exam 70-461 Querying Microsoft SQL Server 2012 Version: 13.0 [ Total Questions: 153 ] Question No : 1 CORRECT TEXT Microsoft 70-461 : Practice Test You have a database named Sales that
More informationQUETZALANDIA.COM. 5. Data Manipulation Language
5. Data Manipulation Language 5.1 OBJECTIVES This chapter involves SQL Data Manipulation Language Commands. At the end of this chapter, students should: Be familiar with the syntax of SQL DML commands
More informationMIS2502: Data Analytics SQL Getting Information Out of a Database Part 1: Basic Queries
MIS2502: Data Analytics SQL Getting Information Out of a Database Part 1: Basic Queries JaeHwuen Jung jaejung@temple.edu http://community.mis.temple.edu/jaejung Where we are Now we re here Data entry Transactional
More informationTable Joins and Indexes in SQL
Table Joins and Indexes in SQL Based on CBSE Curriculum Class -11 By- Neha Tyagi PGT CS KV 5 Jaipur II Shift Jaipur Region Neha Tyagi, PGT CS II Shift Jaipur Introduction Sometimes we need an information
More informationMicrosoft Exam Transition Your MCTS on SQL Server 2008 to MCSA: SQL Server 2012, Part 1 Version: 7.8 [ Total Questions: 183 ]
s@lm@n Microsoft Exam 70-457 Transition Your MCTS on SQL Server 2008 to MCSA: SQL Server 2012, Part 1 Version: 7.8 [ Total Questions: 183 ] Question No : 1 You have a database that contains the tables
More informationL12: ER modeling 5. CS3200 Database design (sp18 s2) 2/22/2018
L12: ER modeling 5 CS3200 Database design (sp18 s2) https://course.ccs.neu.edu/cs3200sp18s2/ 2/22/2018 200 Announcements! Keep bringing your name plates J Exam 1 discussion: questions on grading: Piazza,
More informationUnit Assessment Guide
Unit Assessment Guide Unit Details Unit code Unit name Unit purpose/application ICTWEB425 Apply structured query language to extract and manipulate data This unit describes the skills and knowledge required
More informationSQL Coding Guidelines
SQL Coding Guidelines 1. Always specify SET NOCOUNT ON at the top of the stored procedure, this command suppresses the result set count information thereby saving some amount of time spent by SQL Server.
More informationConsuming and Manipulating Data O BJECTIVES
O BJECTIVES This chapter covers the following Microsoft-specified objectives for the Consuming and Manipulating Data section of Exam 70-316, Developing and Implementing Windows-Based Applications with
More informationSQL Interview Questions
SQL Interview Questions SQL stands for Structured Query Language. It is used as a programming language for querying Relational Database Management Systems. In this tutorial, we shall go through the basic
More informationAnswer: The tables being joined each have two columns with the same name and compatible data types, and you want to join on both of the columns.
Page 1 of 22 Item: 1 (Ref:Cert-1Z0-071.6.2.4) In which situation would you use a natural join? The tables being joined do not have primary and foreign keys defined. The tables being joined have matching
More informationBulkmanager User manual
Bulkmanager User manual 1 INTRODUCTION... 3 2 INSTALLATION... 4 3 USING BULK MANAGER... 5 3.1 Query data... 5 3.2 Select criteria options... 6 3.3 Overview... 6 3.4 Select additional columns... 7 3.5 Drag
More informationGeneral Concepts SQL SERVER REDUCING INDEX FRAGMENTATION
Article: Reducing Index Fragmentation Date: 08/03/2012 Posted by: HeelpBook Staff Source: Link Permalink: Link SQL SERVER REDUCING INDEX FRAGMENTATION General Concepts When you perform any data modification
More informationDB - Week 3 Lab1-2 Introduction to Databases. Dina A. Said
DB - Week 3 Lab1-2 Introduction to Databases Dina A. Said dasaid@ucalgary.ca Relationships Create a relationship as follows: One-to-many s.t. field author_id in titles table is a foreign key from field
More informationOracle Introduction to PL/SQL
Oracle Introduction to PL/SQL 1. For which column would you create an index? a. a column that is small b. a column that is updated frequently c. a column containing a wide range of values d. a column with
More informationCustomize. Building a Customer Portal Using Business Portal. Microsoft Dynamics GP. White Paper
Customize Microsoft Dynamics GP Building a Customer Portal Using Business Portal White Paper Helps you implement a customer portal and create web pages and web parts specifically designed for your customers.
More informationWorking with Structured Data in Microsoft Office SharePoint Server 2007 (Part 4): SharePoint Designer
Working with Structured Data in Microsoft Office SharePoint Server 2007 (Part 4): SharePoint Designer Applies to: Microsoft Office SharePoint Server 2007, Microsoft Office SharePoint Designer 2007 Explore
More informationSQL Fundamentals. Chapter 3. Class 03: SQL Fundamentals 1
SQL Fundamentals Chapter 3 Class 03: SQL Fundamentals 1 Class 03: SQL Fundamentals 2 SQL SQL (Structured Query Language): A language that is used in relational databases to build and query tables. Earlier
More informationAdvance SQL: SQL Performance Tuning. SQL Views
Advance SQL: SQL Performance Tuning SQL Views A view is nothing more than a SQL statement that is stored in the database with an associated name. A view is actually a composition of a table in the form
More informationSeminar 3. Stored procedures. Global variables. Dynamic Execution. The OUTPUT clause. Cursors
Seminar 3. Stored procedures. Global variables. Dynamic Execution. The OUTPUT clause. Cursors Transact-SQL Server Stored Procedures A stored procedure is a group of Transact-SQL statements compiled into
More informationGet Table Schema In Sql Server 2008 To Add Column If Not Exists >>>CLICK HERE<<<
Get Table Schema In Sql Server 2008 To Add Column If Not Exists IF NOT EXISTS ( SELECT * FROM sys.columns WHERE object_id = OBJECT_ID(N'(dbo). Also try catch is easily possible to use in sql serverand
More informationCS352 - DATABASE SYSTEMS
CS352 - DATABASE SYSTEMS Database Design Project - Various parts due as shown in the syllabus Purposes: To give you experience with developing a database to model a real domain At your option, this project
More information