###BeginCaseStudy###
Case Study: 4
Scenario 4
Application Information
You are a database administrator for a manufacturing company.
You have an application that stores product data. The data will be converted to technical
diagrams for the manufacturing process.
The product details are stored in XML format. Each XML must contain only one product that
has a root element named Product. A schema named Production.ProductSchema has been
created for the products xml.
You develop a Microsoft .NET Framework assembly named ProcessProducts.dll that will be
used to convert the XML files to diagrams. The diagrams will be stored in the database as
images. ProcessProducts.dll contains one class named ProcessProduct that has a method
name of Convert(). ProcessProducts.dll was created by using a source code file named
ProcessProduct.es.
All of the files are located in C:\Products\.
The application has several performance and security issues.
You will create a new database named ProductsDB on a new server that has SQL Server
2012 installed. ProductsDB will support the application.
The following graphic shows the planned tables for ProductsDB:
You will also add a sequence named Production.ProductID_Seq.
You plan to create two certificates named DBCert and ProductsCert. You will create
ProductsCert in master. You will create DBCert in ProductsDB.
You have an application that executes dynamic T-SQL statements against ProductsDB. A
sample of the queries generated by the application appears in Dynamic.sql.
Application Requirements
The planned database has the following requirements:
• All stored procedures must be signed.
• The amount of disk space must be minimized.
• Administrative effort must be minimized at all times.
• The original product details must be stored in the database.
• An XML schema must be used to validate the product details.
• The assembly must be accessible by using T-SQL commands.
• A table-valued function will be created to search products by type.
• Backups must be protected by using the highest level of encryption.
• Dynamic T-SQL statements must be converted to stored procedures.
• Indexes must be optimized periodically based on their fragmentation.
• Manufacturing steps stored in the ManufacturingSteps table must refer to a product by
the sameidentifier used by the Products table.
ProductDetails_Insert.sql
Product, xml
All product types are 11 digits. The first five digits of the product id reference the category of
the product and the remaining six digits are the subcategory of the product.
The following is a sample customer invoice in XML format:
IndexManagement.sql
###EndCaseStudy###
Which code segment should you use to define the ProductDetails column?
A.
ProductDetails xml (DOCUMENT Production.ProductDetailsSchema) NULL
B.
ProductDetails xml NULL
C.
ProductDetails xml (CONTENT Production.ProductDetaiisSchema) NULL
D.
ProductDetailsvarchar(MAX) NULL
The product details are stored in XML format. Each XML must contain only one product that
has a root element named Product.
So I think A is correct.
Let’s look at : Example: Specifying Facets to Constrain a Typed xml Column
from here https://msdn.microsoft.com/pl-pl/library/ms184277(v=sql.110).aspx
1. You develop a Microsoft .NET Framework assembly named ProcessProducts.dll that will be used to convert the XML files to diagrams. The diagrams will be stored in the database as images.
2. In the ProductDetails_Insert.sql procedure, the INSERT INTO… SELECT statement actually shreds the XML data into its relational counterpart by using the OPENXML method. Hence, what is stored in the database are the converted XML files (diagrams) equivalent of the Product Details.
3. This same procedure executed both the sp_xml_preparedocument and sp_xml_removedocument; both procedures used when preparing the buffer cache for manipulating XML data in order to obtain its RELATIONAL equivalent.
Therefore, the ProductDetails column for this project will not store XML data, but ‘images’ data using varchar(MAX) data type.
I think the answer to this is A as well. The XML schema is required to be validated per this line in the case. An XML schema must be used to validate the product details. This article discusses using non xml data types to store xml date but does that does not apply when the when the schema must be validated.
• An XML schema must be used to validate the product details.
https://www.simple-talk.com/sql/learn-sql-server/sql-server-xml-questions-you-were-too-shy-to-ask/
In some cases, however, you don’t need any of the features that the xml data type provides. For example, you might be storing product manuals that are accessed only in their entirety. If the manual is modified, the xml value itself is replaced with the new document. You never need to query or modify individual components, and you don’t care about the XML being validated. In a situation such as this, you should use a large object data type to avoid the extra validating processes that the database engine performs for an xml column. In general, whenever your application is simply storing and retrieving the entire XML instance or you want to preserve an XML instance in its original form, as might be the case with legal documents, you should stick with large object storage.
I would agree that if the XML schema is being validated in the .dll vice at the database level then D would be the best answer.
As per option A, there is no Production.ProductDetailsSchema that could be used within the DB for validation. What is available is Production.ProductSchema. So, syntactically, options A & C are wrong!!
the answer is D.
Look at ProductDetails_Insert.sql
Parameters are @xml nvarchar(1000)
In the coressponding insert statement this @xml is used for the second column which is ProductDetails