1 / 32

SQLXML 의 세부 기능 소개 정 홍주 WebTime Feelanet

SQLXML 의 세부 기능 소개 정 홍주 WebTime Feelanet. 목차. Updategram Differgram Bulk Load Using Mapping Schemas URL 을 통한 HTTP Access Optimizing SQLXML Performance. INSERT UPDATE DELETE. XML delivery data. Updategram. XML Data 를 SQL Server 로 갱신 Insert,Delete,Update 문 자동 생성. Supplier.

foy
Download Presentation

SQLXML 의 세부 기능 소개 정 홍주 WebTime Feelanet

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SQLXML의 세부 기능 소개 정 홍주WebTimeFeelanet

  2. 목차 • Updategram • Differgram • Bulk Load • Using Mapping Schemas • URL을 통한 HTTP Access • Optimizing SQLXML Performance

  3. INSERT UPDATE DELETE XML delivery data Updategram • XML Data를 SQL Server로 갱신 • Insert,Delete,Update문 자동 생성 Supplier Shipping Co.

  4. Updategram 구조 • xml-updategram 네임스페이스 • <sync> element • “before” & “after”데이터 image <root xmlns:updg="urn:schemas-microsoft-com:xml-updategram"> <updg:sync [mapping-schema=mapping schema]> <updg:before> XML Fragment </updg:before> <updg:after> XML Fragment </updg:after> </updg:sync> </root>

  5. Mapping Updategram • Default Mapping • XML element,attribute 는 동일한 이름을 가진 데이터베이스의 컬럼으로 Mapping • attribute-centric, element-centric, or mixed • Explicit Mapping • <sync> element 의 mapping-schema attribute 에 지정한 부분으로 적용(XSD)

  6. Inserting Data • Row Insert • after부분에 처리 • IDENTITY Values, GUID <InsertProduct xmlns:updg="urn:schemas-microsoft-com:xml-updategram"> <updg:sync> <updg:before /> <updg:after> <Products ProductID="101"/> </updg:after> </updg:sync> </InsertProduct>

  7. Deleting Data • before부분에 처리 • 각 before child element는 유일하게 single record로 구분되어야 함 <DeleteProduct xmlns:updg="urn:schemas-microsoft-com:xml-updategram"> <updg:sync> <updg:before> <Products ProductID="101"/> </updg:before> <updg:after> </updg:after> </updg:sync> </DeleteProduct>

  8. Updating Data • “before”와“after”부분에 처리 • 여러 row는 id로 match <UpdateProduct xmlns:updg="urn:schemas-microsoft-com:xml-updategram"> <updg:sync > <updg:before> <Products ProductID="101"/> </updg:before> <updg:after> <Products UnitPrice="$752.99"/> </updg:after> </updg:sync> </UpdateProduct>

  9. Using Parameters • <updg:header>에 parameter 지정 • $를 사용 parameter 처리 <UpdateProduct xmlns:updg="urn:schemas-microsoft-com:xml-updategram"> <updg:header> <updg:param name="ProductID"/> <updg:param name="NewCategory"/> </updg:header> <updg:sync > <updg:before><products CategoryID="$NewCategory"/> <Products ProductID="$ProductID"/> </updg:before> <updg:after /> </updg:sync> </UpdateProduct>

  10. Differgram • Differgram 도 template , xml file • URL 쿼리,ADO,.NET Managed Class에서 사용 <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"> <DataInstance> <Customer diffgr:id="Customer1" msdata:rowOrder="0" diffgr:hasChanges="inserted" CustomerID="ALFKI"> <CompanyName>C3Company</CompanyName> <ContactName>C3Contact</ContactName> <Order diffgr:id="Order1" msdata:rowOrder="0" diffgr:hasChanges="inserted" CustomerID="ALFKI" OrderID="1"/> </Customer> </DataInstance>

  11. Extranet Catalog Bulk Load facility Bulk Load • XML Data를 SQL Server로 Bulk Load • COM Component • 대량의 데이터처리, 빠른 성능 Supplier Retailer

  12. Using SQLXMLBulkLoad • SQLXMLBulkLoad Object를 생성 • Execute Method를 이용 Data와 매핑을 로드 • Mapping schema, XML source parameter Set objBL=CreateOhect("SQLXMLBulkLoad.SQLXMLBulkLoad") objBL.Execute "c:\productschema.xml", "c:\products.xml"

  13. Purchase order schema Purchase order Catalog Catalog schema Using Mapping Schemas Supplier Retailer

  14. Using Mapping Schemas • XML 문서표현에 대한 동의 • Relation Data와 XML간의 mapping정보 • Schema의 일종 생성 • XML-Data Reduced (XDR) • XML Schema(XSD)

  15. Mapping • XML-SQL, xmlns:xsd namespace • Default mapping 적용 • sql:relation 주석을 사용 table 또는 view 의 alias를 생성 • sql:field 주석을 사용 column의 alias를 생성

  16. 예) Default Mapping <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema“ xmlns:msdata="urn:schemas-microsoft-com:mapping-schema“> <xsd:element name=“Customers”> <xsd:complexType> <xsd:attribute name=“CustID”/> </xsd:complexType> </xsd:element > </xsd:schema> 관계형 데이터:Customers XML View CustID ------ A NULL B <Customers CustID=“A”/> <Customers/> <Customers CustID=“B”/>

  17. 예) Explicit Mapping <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema“ xmlns:msdata="urn:schemas-microsoft-com:mapping-schema“> <xsd:element name=“Customers”msdata:relation=“UserObject"> <xsd:complexType> <xsd:attribute name=“ID”msdata:field=“SECOrgID"/> </xsd:complexType> </xsd:element > </xsd:schema> 관계형 데이터: UserObject XML View SECOrgID ------ A NULL B <Customers ID=“A”/> <Customers/> <Customers ID=“B”/>

  18. 예) Join Mapping <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:mapping-schema"> <xsd:element name="Customer"msdata:relation="Customers"> <xsd:complexType> <xsd:sequence> <xsd:element name="Order"msdata:relation="Orders"> <xsd:annotation><xsd:appinfo> <msdata:relationship parent="Customers" parent-key="CustomerID" child="Orders" child-key="CustomerID" /> </xsd:appinfo></xsd:annotation> <xsd:complexType> <xsd:attribute name="OrderDate" type="xsd:dateTime"/> </xsd:complexType> </xsd:element> </xsd:sequence> <xsd:attribute name="CustomerID" /> </xsd:complexType> </xsd:element> </xsd:schema>

  19. Filtering Data • sql:limit-field 와sql:limit-value 사용 <xsd:annotation> <xsd:appinfo> <sql:relationship name="CustAddr“ parent="Customer" parent-key="CustomerID" child="Addresses" child-key="CustomerID" /> </xsd:appinfo> </xsd:annotation> <xsd:sequence> <xsd:element name="BillTo" type="xsd:string" sql:relation="Addresses" sql:field="StreetAddress" sql:limit-field="AddressType" sql:limit-value="billing" sql:relationship="CustAddr" >

  20. Using Constants • sql:is-constant 사용 • 1 이면 mapping되지 않음 <xsd:element name="CustomerOrders" sql:is-constant="1" > <xsd:complexType> <xsd:sequence> <xsd:element name="Order" sql:relation="Orders" sql:relationship="CustOrders" maxOccurs="unbounded" > <xsd:complexType> <xsd:attribute name="OrderID"

  21. Schema를 이용 데이터 검색 • XPath 를 이용하여 select • <sql:xpath-query> element • Schema Virtual Name 게시 • schema/Schema2.xml/Customers[@CustomerID="ALFKI"] • SqlXmlCommand 클래스를 이용 • <sql:xpath-query> element • Template 인라인 Mapping Schema

  22. Browser Supplier Extranet Intranetsite Catalog Web site Application Retailer Shipping Co. Browser URL을 통한 HTTP Access • HTTP를 통한 SQL Server Data게시 • URL 쿼리, XML View, POST, Template

  23. Vir-Directory Architecture Clients Internet Information Services SQL Server 2000 http://webserver/data Web browser An XML document Virtual directory Business partners Virtual name HTTP-aware applications …FOR XML… OLE DB Sqlisapi.dll Sqlxmlx.dll

  24. Virtual Directory 생성 • 이름과 실제 경로 지정 • 데이터베이스 선택 • 보안 구현 • HTTP option 선택 • virtual name 생성template 파일, mapping schema, database object 또는 soap • 추가적인 parameter 지정

  25. HTTP Access 테스트 • URL 쿼리를 이용 할 수 있도록 선택 • root element를 지정 http://webserver/data? sql=SELECT productname, unitprice FROM products FOR XML AUTO&root=catalog

  26. XML Template 파일 • 하나이상의 SQL statements 또는 XPath 쿼리로 이루어진 valid XML 문서 • 서버사이드 • Parameter 허용 <?xml version="1.0"?> <catalog xmlns:sql='urn:schemas-microsoft-com:xml-sql'> <sql:query> SELECT productid, productname, unitprice FROM products product FOR XML AUTO </sql:query> </catalog>

  27. Template File 게시 • template file이 있는 폴더에 virtual name 지정 http://webserver/data/templates/catalog.xml Object Physical path Name webserver Web server data Virtual directory C:\SQLSite templates Virtual name C:\Templates catalog.xml Template file C:\Templates\catalog.xml

  28. Webserver C:\SQLSite (Virtual root data) C:\Schemas (Virtual name schemas) inv.xml Schema Virtual Name 게시 • Schema를 담고있는 폴더를 virtual name으로 구현 • 클라이언트에서는 URL을 이용하여 schema를 액세스 http://webserver/query/schemas/inv.xml/Item?root=Invoice

  29. dbobject Virtual Name 게시 • BLOB 데이터를 처리하기 위해 dbobject virtual name 구현(예 image) • AUTO 모드에서 처리되는 binary object 를 처리 • path 는 미지정됨 • 단지 각 virtual directory에 하나만 지정 • XPath 쿼리 허용

  30. URL을 통한 dbobject • Xpath 적용 • 스타일 시트의 IMAGE 태그의 src로 dbobject 사용 dbobject/categories[@categoryid='1']/@picture <IMG> <xsl:attribute name='SRC'> http://webserver/data/ <xsl:value-of select='@picture'/> </xsl:attribute> </IMG>

  31. SOAP Virtual Name 게시 • SP,Template 로 soap virtual name적용 http://IISServer/nwind/SoapVirtualName?wsdl

  32. SQLXML 성능 최적화 • Caching • Template Caching • XSLT Stylesheet Caching • Schema Caching • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServr\Client\SQLXML3 • SQLXMLOLEDB • con.open "Provider=SQLXMLOLEDB;data provider=sqloledb;

More Related