使用者:Yyaootw/新遊戲

出自 shoutwiki
前往: 導覽搜尋

http://zh.wikipedia.org/wiki/WinFS WinFS 模板:Distinguish 模板:RoughTranslation

WinFS(全名為Windows Future Storage[1]是以關聯式資料庫為基礎之資料儲存與管理系統的代號名稱,它是由Microsoft所開發,並在2003年首次用於Microsoft Windows 作業系統中的進階儲存子系統,它是針對結構化半結構化未結構化資料保存與管理用途所設計。WinFS包含可用於儲存資訊的關聯式資料庫,而且可以儲存任何類型的資料,前提是資料類型已經有完整定義的結構描述。接著,您就可以透過關係來建立個別資料項目之間的關聯,這樣系統便可以根據特定屬性來參照,使用者也可以明確地描述屬性來參照。此外,因為資料具有完整定義的結構描述,任何應用程式都可以重複使用資料;而且透過使用關係,可以有效率地組織與擷取相關資料。因為系統知道資訊的結構與用途,因此可以進行複雜的查詢,以達成資料的進階搜尋,並透過探索資料項目之間的關係來彙整各種不同的資料項目。

檔案:WinFSCalendar.png
原型行事曆應用程式依日期排序影像,並使用影像與連絡人之間的關係來篩選影像。WinFS的目的是提供共用結構描述系統,以應用於此類案例。

WinFS與其共用類型結構描述可以讓應用程式識別不同的資料類型,但您仍需要撰寫應用程式以轉譯不同的資料類型。因此,WinFS並不適合用來開發可檢視或編輯所有資料類型的單一應用程式;它的目的是讓應用程式能夠瞭解所有資料的結構並擷取資訊以進行進一步處理。當Microsoft首度在2003 专业开发人员大会介紹WinFS時,也發佈了視訊簡報,名稱為IWish,[2],此視訊簡報提供的原型介面顯示應用程式如何公開介面以利用統一類型系統的好處。視訊中展示的概念包含應用程式如何使用資料項目之間的關係來動態篩選選項,以及應用程式如何將多個相關資料組成群組並以統一的呈現方式呈現資料。

WinFS是眾多"Longhorn"技術的基礎,而且將包含在下一個版本的Windows中。原本WinFS應該在Windows Vista發行之後提供,但相關計畫在2006年6月遭到擱置,然而其某些元件技術已整合到即將發行的ADO.NETMicrosoft SQL Server[3] 據某些觀察家指出WinFS專案已完成,但史蒂夫·鲍尔默在2006年11月公開說明WinFS仍在開發中,至於此技術將以何種方式提供仍未知。。[4]

動機[編輯]

許多常見作業系統中的檔案系統(包括近來許多Microsoft Windows版本中使用的NTFS檔案系統)都指示將檔案與其他物件儲存為位元組資料流,而且這些檔案系統對於檔案中所儲存的資料通常所知甚少或一無所知。此類檔案系統也只提供組織檔案的單一方式(具體而言是透過目錄與檔案名稱)。[5][6]

因為檔案系統對於其所儲存的資料一無所知,[5]應用程式通常會使用本身的檔案格式(通常為專屬格式)。這對於在多個應用程式之間共用資料是一大阻礙。要建立可處理來自多種檔案類型之資訊的應用程式變得很困難,因為程式設計師必須瞭解所有檔案的結構語意[7] 使用常見的檔案格式是此問題的暫時性解決方案,但並非根本之道;因為您並無法確保所有應用程式都會使用預期的格式。具有標準化結構描述的資料(例如,XML文件與關聯式資料)沒有此問題,因為它們具有標準化的結構與執行階段需求。[8]

此外,傳統檔案系統可以只根據檔案名稱來擷取與搜尋資料,因為它對於資料所知的範圍僅止於用以儲存資料之檔案的名稱。[7] 比較好的解決方案是使用屬性為檔案加上標記(tag),此處所謂的屬性可描述檔案內容。屬性是有關檔案的中繼資料,例如檔案類型(例如,文件圖片音樂建立者等)。[5] 這樣可讓系統依屬性(而非使用資料夾階層)來搜尋檔案,例如尋找"包含人員X的圖片"。檔案系統本身即可識別屬性,或透過某些延伸模組來識別屬性。[5] 桌面搜尋應用程式進一步採用此概念。它們會從檔案擷取資料(包含屬性)並為檔案編製索引。為了擷取資料,它們為每種檔案格式使用一個篩選器。這樣就可以依照檔案屬性與檔案中所包含的資料來搜尋檔案。[5]

但是,這仍不足以協助管理相關資料,因為不同的項目之間並未定義任何關係。例如,您無法搜尋"住在墨西哥阿卡波可市、在我的相片集中出現超過一百次、且我最近一個月曾經與其有過電子郵件往來的所有人員的電話號碼"。若要完成這種搜尋,必須有一種同時定義語意與資料關係的資料模型。[5][6] WinFS 的目的是提供這樣的資料模型與執行階段基礎結構,以便儲存資料與資料項目之間的關係(根據資料模型),同時以儘可能不影響效能的方式完成此動作。

概觀[編輯]

WinFS可識別各種類型的資料,例如圖片電子郵件文件音訊視訊行事曆連絡人等;不像檔案系統只能識別位元組資料流。由系統儲存與管理的資料是WinFS執行階段所識別之資料類型的執行個體。資料結構的基礎是屬性。例如,履歷類型的執行個體將透過公開特定屬性(例如姓名教育程度工作經驗等)來描述資料。屬性的類型可能是字串整數日期等簡單類型,或連絡人之類的複雜類型。[7][9] 不同的資料類型會公開不同的屬性。此外,WinFS也允許不同的資料執行個體與彼此關聯,例如您可以利用作者關係來建立文件與連絡人之間的關聯。[9][6] 關係也會公開為屬性,例如若文件是透過建立者關係與連絡人關聯,則文件將具有建立者屬性。當文件被存取時,系統會偵測到該關係並傳回相關資料。[9] 藉由依循該關係即可擷取所有相關資料。[6]

檔案:WinFSemail.png
電子郵件應用程式可以使用關係來建立動態篩選器,以建立不同的電子郵件檢視,如同在原型行事曆截圖一樣

WinFS透過讓所有應用程式存取資料類型與其結構描述的方式來達成應用程式之間的資料共用。[7] 因此當任何應用程式想要使用WinFS類型時,可以使用結構描述來瞭解資料的結構,並有效利用資訊。因此,即使開發人員並未撰寫剖析器來識別不同的資料格式,應用程式也可以存取系統上的所有資料。它也可以使用關係與相關資料來建立動態篩選器,以不同的方式呈現應用程式所處理的資訊。WinFS API進一步將資料的存取工作抽象化。所有WinFS類型都公開為.NET 物件,而物件的屬性則直接對應到資料類型的屬性。[5] 此外,透過讓處理相同資料的不同應用程式共用相同的WinFS資料執行個體,而非將相同的資料儲存為不同的檔案格式,系統管理員便不需要在資料發生變更時同步不同的存放區。[10] 因此WinFS可協助避免資料重複儲存的情形。[8][5]

透過存取系統中所有資料的能力,您可以建立複雜的搜尋來尋找由WinFS所管理之所有資料項目中的資料。在上述範例("住在墨西哥阿卡波可市、在我的相片集中出現超過一百次、且我最近一個月曾經與其有過電子郵件往來的所有人員的電話號碼")中,WinFS可以周遊所有相片的主體關係以尋找連絡人項目。同樣地,它也可以篩選最近一個月的電子郵件並存取通訊對象關係以與連絡人聯繫。接著,系統便可以從上述兩個搜尋結果中找出適當的連絡人,並透過存取連絡人項目的適當屬性來擷取其電話號碼。

除了完全語意化的資料(如同XML關聯式資料)之外,WinFS也支援半結構化資料(例如影像,影像具有未結構化的位元資料流與結構化的中繼資料)以及未結構化資料(例如檔案)。它可以將未結構化的元件直接儲存為檔案,同時將結構化的中繼資料儲存在結構化的 存放區中。[9] WinFS在內部使用關聯式資料庫來管理資料。但是,它不會將資料限制為屬於任何特定資料模型,例如關聯式階層式,而且它可以是任何已完整定義的結構描述。WinFS執行階段會將結構描述對應到關聯式特徵(modality)[5],方式是定義將儲存類型的資料表,以及重新呈現關係時所需的主索引鍵外部索引鍵。WinFS預設包含物件與XML結構描述的對應;至於其他結構描述的對應,則必須另行指定。物件結構描述是使用XML來指定;WinFS會產生指令碼以將結構描述公開為.NET 類別。您可以使用ADO.NET直接指定關聯式結構描述,雖然您必須提供物件結構描述的對應以將它以類別方式公開。[9] 所有關係周遊動作都是在這些資料表上以Joins方式執行。WinFS也會自動在這些資料表上建立索引,以便應用程式可以更快速地存取資訊。[9] 索引可大幅加快Joins的速度,因此周遊關係以擷取相關資料的動作非常快。搜尋資訊時也會使用索引;搜尋與查詢會使用索引,因此操作可以快速完成,這跟桌面搜尋系統非常像。

發展[編輯]

模板:Graphical timeline

WinFS的開發是1990年代早期計畫之功能的延續,此功能稱為物件檔案系統(Object File System,簡稱OFS),它原本應該包含在Cairo專案中。OFS被認為應該具有強大的資料彙整功能。[11] 但Cairo專案當時遭擱置,因此OFS也被延宕。但是,稍後在開發COM時,規劃了一個稱為Storage+(以後來發行的SQL Server 8.0為基礎)的儲存系統,Storage+預期應提供類似的彙整功能。[11] 但是,這項計畫也沒有實現,而類似的技術關聯式檔案系統(Relational File System,RFS)據信將在SQL Server 2000中提供。[11]但是,SQL Server 2000最後只是對於SQL Server 7.0進行些許更新,但並未實作RFS。

但這個概念從未被忘卻。[11] 因此今日才有WinFS的出現。WinFS原本預計包含在Windows Vista中,[12]以及後來代號名稱為"Longhorn"的Windows Vista組建4051(此版本是在2003年的Microsoft Professional Developers Conference發給開發人員),但當時WinFS有嚴重的效能問題。[11] 在2004年8月,Microsoft宣布WinFS將不會內建於Windows Vista;而是會在Vista發行後以可下載的更新方式提供。[11]

20058月29日[11] Microsoft悄悄地將WinFS Beta 1提供給MSDN訂戶。該版本可以在Windows XP運作,而且需要.NET Framework才能執行。WinFS API包含在System.Storage命名空間中。[13] 該Beta版本在2005年12月1日更新,以與.NET Framework 2.0版相容。[14] WinFS Beta 2預計在2006年末推出,[15],而且預期會與Windows 桌面搜尋整合,因此搜尋結果會包含來自一般檔案與WinFS存放區的結果;此外,您可以使用ADO.NET來存取WinFS資料。[16]

但是,在2006年6月23日,Microsoft的WinFS團隊宣布將不再以獨立產品方式提供WinFS,[3]而且某些元件將以其他技術提供 - 例如物件關聯式對應元件至ADO.NET Entity Framework;支援未結構化資料、操作的無管理模式、透過FILESTREAM資料類型支援檔案系統物件,以及SQL Server 2008(後來的代碼名稱為Katmai)中的階層式資料[17][18],以及與Win32 APIWindows Shell整合,以及在未來的Microsoft SQL Server版本中透過周遊關係以支援階層的周遊;[17]以及將元件同步到Microsoft Sync Framework[17] However, having a shared-schema storage system built into a future iteration of Microsoft Windows hasn't been ruled out yet.[17]

Microsoft宣布此消息之後,大部分的分析師均認為WinFS專案已被放棄。但在2006年11月,Steve Ballmer在一場會談中說明WinFS仍在開發中,但要等到技術成熟時才會整合到Windows程式碼基底。引用錯誤:缺少 <ref> 標籤的結束標籤 </ref>

資料存放區[編輯]

架構[編輯]

檔案:WinFSArch.svg
Architecture of the WinFS Stack

WinFS不是實體檔案系統;相反地,它在NTFS檔案系統之上提供系統化的資料模型建構能力。它仍然使用NTFS在實體檔案中儲存其資料。[11]。 WinFS使用從SQL Server 2005[19]衍生的關聯式引擎來提供資料關係機制。WinFS存放區僅是已設定FILESTREAM屬性的SQL Server資料庫(.MDF)檔案[20]。這些檔案是儲存在磁碟區根目錄下名為"System Volume Information"的資料夾(此資料夾具有限制的存取權)下的"WinFS"子資料夾中,其名稱為這些存放區的GUID[20]

WinFS 堆疊的底層是WinFS Core,它會與檔案系統互動並提供檔案存取與定址能力。[7] 關聯式引擎使用WinFS核心服務來提供結構化的存放區與其他服務(例如,鎖定將使用哪個WinFS執行階段來實作該功能。WinFS執行階段會公開服務(例如同步處理規則),其可用於同步處理WinFS存放區或在發生特定事件時執行特定動作。[7]

WinFS是以服務的方式執行,此服務會執行三個處理程序[21] - 裝載關聯式資料存放區的WinFS.exe、裝載索引編製與查詢引擎的WinFSSearch.exe,以及與底層檔案系統互動的WinFPM.exe (WinFS File Promotion Manager)。您可以利用一組.NET Framework API來撰寫程式以存取其功能,這些.NET Framework API可讓應用程式定義自訂資料型別、定義資料之間的關係、儲存與擷取資訊,以及實作進階搜尋。[5][7] 接著應用程式可以彙整資料,並將資料呈現給使用者。

資料存放區[編輯]

WinFS將資料儲存在關聯式存放區中,這些存放區會公開為虛擬位置,稱為存放區[11] WinFS存放區是通用存放庫,任何應用程式都可以在其中儲存資料,以及中繼資料、資料關係與結構描述。WinFS執行階段本身可以套用特定的資料關係;例如,若圖片的subject屬性與連絡人的name屬性相同,則WinFS可以在該連絡人與該圖片之間建立關聯。[22] 資料之間的關係也可以由其他應用程式或使用者指定。[23]

WinFS 提供一致性的存放區,但無法定義將儲存於存放區之資料的格式。但是,它支援以應用程式支援的特定格式寫入資料。前提是應用程式必須提供結構描述,以定義解譯檔案格式的方式。[5] 例如,您可以新增結構描述以讓WinFS知道如何讀取(甚至是進一步搜尋或分析)特定檔案格式,例如PDF檔案。透過使用結構描述,任何應用程式都可以讀取由其他應用程式所建立的資料,而且不同的應用程式也可以透過共用結構描述以其他應用程式支援的格式來寫入資料。[23]

您可以在一部電腦上建立多個WinFS存放區。[23] 這樣可以獨立儲存不同類別的資料,例如,您可以將公司文件與私人文件儲存在不同的存放區中。根據預設,WinFS只提供一個存放區,其名稱為"DefaultStore"。[11] WinFS存放區是公開為殼層(shell)物件(類似虛擬資料夾),此物件會動態產生存放區中的項目清單,並以資料夾檢視方式呈現這些項目。利用殼層物件也可以搜尋資料存放區中的資訊。[11]

資料單位是以WinFS 項目的方式儲存在WinFS存放區中。[23][5] WinFS 項目與核心資料項目亦包含資料項目與其他資料之關聯的資訊。此關聯是以邏輯連結的方式儲存。連結指的是目前的項目與哪些資料項目關聯。換句話說,連結是用以指定資料與其他資料項目的關係。連結實體上是以連結識別碼來儲存,此識別碼指定資料關聯的名稱與用途,例如,所屬型別組成要素[5] 連結識別碼是儲存為資料項目的屬性(attribute)。具有相同連結識別碼的所有物件將被視為相關物件。[5] 您必須事先將XML 結構描述(定義將儲存在WinFS中之資料項目的結構)提供給WinFS執行階段。[5] 在WinFS的Beta 1版本中,您必須先將結構描述組件新增到GAC,才能開始使用結構描述。

資料模型[編輯]

WinFS模型資料會使用資料項目、其關聯、延伸(extension)與規則來規範其使用方式。[7] WinFS必須知道資料項目的類型與結構,才能將資料項目中儲存的資訊提供給要求該資訊的應用程式。這是透過使用結構描述來完成。對於即將儲存在WinFS中的每種資料項目類型,您必須提供對應的結構描述,以定義資料的類型、結構與關聯。這些結構描述是使用XML來定義。[5]

預先定義的WinFS結構描述不僅包含文件、電子郵件、約會、工作、媒體、音訊、視訊等的結構描述;也包含系統結構描述,其中包括組態、程式與其他系統相關資料。[7] 如果要讓應用程式在WinFS中儲存資料,但不想與其他應用程式共用該資料的結構,或這些資料可跨系統提供,則可以針對個別應用程式定義自訂結構描述。[7]

型別系統[編輯]

檔案:WinFS1.svg
WinFS Type Hierarchy

檔案系統與WinFS之間最大的差異在於WinFS知道其所儲存之每個資料項目的型別。型別會指定資料項目的屬性(property)。WinFS型別系統與.NET Framework的類別與繼承概念緊密關聯。透過延伸與巢狀化任何預先定義的型別,即可建立新型別。[5]

WinFS提供四種預先定義的基礎型別 – ItemsRelationshipsScalarTypesNestedTypes[5] Item是可儲存的基礎資料物件,而Relationship則是兩個資料項目之間的關係或連結。因為所有WinFS項目都必須具有型別,儲存之項目的型別會定義其屬性(property)。Item的屬性可以是ScalarType(定義屬性可包含之資訊的最小單位)或NestedType(多個ScalarTypes和/或NestedTypes的集合)。所有WinFS型別都以.NET CLR 類別的方式提供。[23]

任何以資料單位(例如,連絡人、影像、視訊或文件等)所代表的物件都可以儲存在WinFS存放區中做為Item型別的特殊項。[23] 根據預設,WinFS為檔案、連絡人、文件、圖片、音訊、視訊、連絡人與郵件提供Item型別。檔案Item可以儲存任何一般資料,這在檔案系統中是儲存為檔案。但除非為檔案提供進階結構描述(透過將它定義為特殊化的Item),WinFS將無法存取其資料。此類檔案Item僅能支援與其他Item相關聯。[5]

檔案:WinFS2.svg
Defining a new Type

開發人員可以擴充這些型別或基礎型別Item,以為其自訂資料提供型別。Item中包含的資料是以屬性或實際儲存資料的欄位來定義。例如,連絡人Item可能包含型別為ScalarType的Name欄位,以及型別為NestedType(進一步由兩個ScalarType組成)的Address欄位。為定義此型別,會擴充基礎類別Item,而且會新增必要欄位至該類別。[5] NestedType欄位可定義為包含兩個ScalarType欄位的另一個類別。一旦定義型別,就必須定義結構描述以表示每個欄位的原始型別,例如Name欄位的型別是String、Address欄位是自訂的Address類別,每個欄位的型別都是String。WinFS支援的其他原始型別包括IntegerByteDecimalFloatDoubleBoolean與DateTime等。[5] 結構描述也會定義哪些欄位為必要欄位,哪些欄位為選用欄位。[24] 系統會使用以此方式定義的連絡人Item來儲存有關連絡人的資訊,方式是填入屬性欄位並予以儲存。首次儲存時只需要填入標示為必要的欄位。[23] 其他欄位可在稍後由使用者填入,或完全不填入。若需要新增多個欄位(例如,"上次交談日期"),只要視需要簡單地擴充此型別即可。您可以使用相同的方式定義其他資料的Item型別。

檔案:WinFS3.svg
Relationships

WinFS會為所有已定義的Item建立資料表[24] 為Item定義的所有欄位會構成資料表的資料欄,而每個對應Item的Item例項則會儲存為資料表的資料列。當資料表中的某些欄位參照某些其他資料表中的資料時,即表示這些資料表之間有特定的關係存在。關係的結構描述會指定相關的資料表有哪些,以及關係的種類與名稱。WinFS執行階段負責管理關係結構描述。[23] 所有Item都會公開為.NET CLR 物件,此物件具有統一的介面,可讓應用程式輕鬆存取欄位中儲存的資料。因此,任何應用程式都可以擷取具有任何Item型別的物件,而且可以使用該物件中的資料,而不需要瞭解欄位中儲存之資料的實際結構。[5]

WinFS型別是公開為.NET類別,它可以具現化為.NET物件。透過設定屬性即可在這些型別中儲存資料。完成之後,它們變會永久儲存至WinFS存放區。使用ItemContext類別(請參閱資料擷取區段以取得詳細資訊)即可存取WinFS 存放區。ItemContext允許以交易式方式存取WinFS存放區,例如,從將ItemContext物件繫結到存放區到因為全部成功而關閉或所有變更都已復原。當資料發生變更時,它們不會寫入到磁碟;而是會寫入到記憶體內的記錄。只有當連線關閉時,變更才會以批次方式寫入磁碟。這樣可協助最佳化磁碟I/O。[9] 下列程式碼片段會建立連絡人並儲存在WinFS存放區中。

 //Connect to the default WinFS store
 using(ItemContext ic = ItemContext.Open())
 {
     //Create the contact and set the data in appropriate properties
     ContactEAddress contact = new ContactEAddress();

     //Name is a ComplexType
     contact.Name = new PersonName();                  
         contact.Name.Displayname = "Doe, John";
         contact.Name.FirstName = "John";
         contact.Name.LastName = "Doe";

     //Telephone number is a ComplexType
     contact.TelephoneNumber = new TelephoneNumber();  //ComplexType
         contact.TelephoneNumber.Country = CountryCode.Antarctica;
         contact.TelephoneNumber.Areacode = 4567;
         contact.TelephoneNumber.Number = 9876543210;

     //Age is a SimpleType
     contact.Age = 111;

    //Add the object to the user's personal folder.
    //This relates the item with the Folder pseudo-type, for backward
    //compatibility, as this lets the item to be accessed in a folder 
    //hierarchy for apps which are not WinFS native.
    Folder containingFolder = UserDataFolder.FindMyPersonalFolder();
    containingFolder.OutFolderMemberRelationship.AddItem(ic, contact);

    //Find a document and relate with the document. Searching begins by creating an
    //ItemSearcher object. Each WinFS type object contains a GetSearcher() method
    //that generates an ItemSearcher object which searches documents of that type.
    using (ItemSearcher searcher = Document.GetSearcher(ic))
    {
         Document d = searcher.Find(@"Title = 'Some Particular Document'");
         d.OutAuthoringRelationship.AddItem(ic, contact);
    }
    //Since only one document is to be found, the ItemContext.FindOne() method
    //could be used as well.

    //Find a picture and relate with it
    using (ItemSearcher searcher = Picture.GetSearcher(ic))
    {
         Picture p = searcher.Find(@"Occasion = 'Graduation' and Sequence = '3'");
         p.OutSubjectRelationship.AddItem(ic, contact);
    }

    //Persist to the store and close the reference to the store
    ic.Update();
    ic.Close();
 }

Relationships[編輯]

A datum can be related to one more item, giving rise to a one-to-one relationship, or with more than one items, resulting in a one-to-many relationship. [25] The related items, in turn, may be related to other data items as well, resulting in a network of relationships, which is called a many-to-many relationship. Creating a relationship between two Items create another field in the data of the Items concerned which refer the row in the other Item’s table where the related object is stored.[23]

檔案:WinFS4.svg
WinFS Relationships

In WinFS, a Relationship is an instance of the base type Relationship, which is extended to signify a specialization of a relation. A Relationship is a mapping between two items, a Source and a Target. The source has an Outgoing Relationship, whereas the target gets an Incoming Relationship.[24] WinFS provides three types of primitive relationships – Holding Relationship, Reference Relationship and Embedding Relationship.[25] Any custom relationship between two data types are instances of these relationship types.

  • Holding Relationships specifies ownership and lifetime (which defines how long the relationship is valid) of the Target Item. For example, the Relationship between a folder and a file, and between an Employee and his Salary record, is a Holding Relationship – the latter is to be removed when the former is removed. A Target Item can be a part of more than one Holding Relationships. In such a case, it is to be removed when all the Source Items are removed.
  • Reference Relationships provide linkage between two Items, but do not have any lifetime associated, i.e., each Item will continue to be stored even without the other.
  • Embedding Relationships give order to the two Items which are linked by the Relationship, such as the Relationship between a Parent Item and a Child Item.

Relationships between two Items can either be set programmatically by the application creating the data, or the user can use the WinFS Item Browser to manually relate the Items.[24] A WinFS item browser can also graphically display the items and how they are related, to enable the user to know how their data are organized.[23]

Rules[編輯]

WinFS includes Rules,[26] which are executed when certain condition is met. WinFS rules work on data and data relationships. For example, a rule can be created which states that whenever an Item is created which contains field "Name" and if the value of that field is some particular name, a relationship should be created which relates the Item with some other Item. WinFS rules can also access any external application. For example, a rule can be built which launches a Notify application whenever a mail is received from a particular contact.[26] WinFS rules can also be used to add new properties fields to existing data Items.[26]

WinFS rules are also exposed as .NET CLR objects. As such any rule can be used for any purpose. A rule can even be extended by inheriting from it to form a new rule which consists of the condition and action of the parent rule plus something more.[26]

RAV[編輯]

WinFS supports creating Rich Application Views (RAV) by aggregating different data in a virtual table format. Unlike database view, where each individual element can only be a scalar value, RAVs can have complex Items or even collection of Items. The actual data can be across multiple data types or instances and can even be retrieved by traversing relationships.[9] RAVs are intrinsically paged (dividing the entire set of data into smaller pages containing disconnected subsets of the data) by the WinFS runtime. The page size is defined during creation of the view and the WinFS API exposes methods to iterate over the pages. RAVs also supports modification of the view according to different grouping parameters. Views can also be queried against.

Access control[編輯]

Even though all data is shared, everything is not equally accessible. WinFS uses the Windows authentication system to provide two data protection mechanisms.[23] First, there is share-level security that controls access to your WinFS share. Second, there is item level security that supports NT compatible security descriptors. The process accessing the item must have enough privileges to access it. Also in Vista there is the concept of "integrity level" for an application. A higher integrity data cannot be accessed by a lower integrity process.

Data retrieval[編輯]

檔案:WinFSFlowChart.svg
Flowchart for creating, searching and updating WinFS data instances.

The primary mode of data retrieval from a WinFS store is querying the WinFS store according to some criteria,[7] which returns an enumerable set of items matching the criteria. The criteria for the query is specified using the OPath query language. The returned data is made available as instances of the type schemas, conforming to the .NET object model.[27] The data in them can be accessed by accessing the properties of individual objects.[24]

Relations are also exposed as properties. Each WinFS Item has two properties, named IncomingRelationships and OutgoingRelationships, which provides access to the set of relationship instances the item participates in. The other item which participates in one relationship instance can be reached through the proper relationship instance.[24][9]

The fact that the data can be accessed using its description, rather than location, can be used to provide end-user organizational capabilities without limiting to the hierarchical organization as used in file-systems. In a file system, each file or folder is contained in only one folder. But WinFS Items can participate in any number of holding relationships, that too with any other items. As such, end users are not limited to only file/folder organization. Rather, a contact can become a container for documents; a picture a container for contacts and so on. For legacy compatibility, WinFS includes a pseudo-type called Folder which is present only to participate in holding relationships and emulate file/folder organization. Since any WinFS Item can be related with more than one Folder item, from an end user perspective, an item can reside in multiple folders without duplicating the actual data.[9] Applications can also analyze the relationship graphs to present various filters. For example, an email application can analyze the related contacts and the relationships of the contacts with restaurant bills and dynamically generate filters like "Emails sent to people I had lunch with".

Searches[編輯]

The WinFS API provides a class called the ItemContext class, which is bound to a WinFS store. The ItemContext object can be used to scope the search to the entire store or a subset of it. It also provides transactional access to the store.[13] An object of this class can then spawn an ItemSearcher object which then takes the type (an object representing the type) of the item to be retrieved or the relationship and the OPath query string representing the criteria for the search.[24][28] A set of all matches are returned, which can then be bound to an UI widget for displaying en masse or enumerating individually.[23] The properties items can also be modified and then stored back to the data store to update the data. The ItemContext object is closed (which marks the end of association of the object with the store) when the queries are made or changes merged into the store.

Related items can also be accessed through the items. The IncomingRelationships and OutgoingRelationships properties gives access to all the set of relationship instances, typed to the name of the relationship. These relationship objects expose the other item via a property. So, for example, if a picture is related to a picture, it can be accessed by traversing the relationship as:

 ContactsCollection contacts = picture.OutgoingRelationships.Cast(typeof(Contact)).Value;
 //This retrieves the collection of all outgoing relationships from a picture object
 //and filters down the contacts reachable from them and retrieves its value.

 //Or the relationship can be statically specified as
 ContactsCollection contacts = picture.OutgoingRelationships.OutContactRelationship.Contact;

模板:Anchor An OPath query string allows to express the parameters that will be queried for to be specified using Item properties, embedded Items as well as Relationships.[29] It can specify a single search condition, such as "title = Something'", or a compound condition such as "title = 'Title 1' || title = 'Title 2' && author = 'Someone'". These boolean and relational operations can be specified using C# like &&, ||, =, != operators as well as their English-like equivalent like EQUAL, NOT EQUAL. SQL like operators such as LIKE, GROUP BY and ORDER BY are also supported, as is wildcard conditions.[29] So, "title LIKE 'any*'" is a valid query string. These operators can be used to execute complex searches such as

 using ( ItemContext ic = ItemContext.Open() )
 {
     //Searching begins by creating a ItemSearcher object. The searcher is created from a
     //relationship instance because the contacts being searched for are in relation. The
     //first parameter defines the scope of the search. An ItemContext as the scope means
     //the entire store is to be searched. Scope can be limited to a set of Items which may
     //be in a holding relationship with the contacts. In that case, the set is passed as
     //the scope of the search.
     ItemSearcher searcher = OutContactRelationship.GetTargetSearcher(ic, typeof(Contact));
     ContactCollection contacts = searcher.FindAll("OutContactRelationship.Contact.Name LIKE 'A*'");
     ic.Close();
 }

The above code snippet creates an ItemSearcher object that searchs on the OutContactRelationship instance that relates pictures and contacts, in effect searching all pictures related with a contact. It then runs the query Name LIKE 'A*'" on all contacts reachable through OutContactRelationship, returning the list of "contacts whose names start with A and whose pictures I have". Similarly more relationships could be taken into account to further narrow down the results.[24][9] Further, a natural language query processor, which parses query in natural language and creates a well-formed OPath query string to search via proper relationships, can allow users to make searches such as "find the name of the wine I had with person X last month", provided financial management applications are using WinFS to store bills.

Different relations specify a different set of data. So when a search is made which encompasses multiple relations, the different sets of data are retrieved individually and a union of the different sets is computed. The resulting set contains only those data items which correspond to all the relations.[24]

Notifications[編輯]

WinFS also includes better support for handling data that changes frequently. Using WinFS Notifications, applications choose to be notified of changes to selected data Items. WinFS will raise an ItemChangedEvent, using the .NET Event model, when a subscribed-to Item changes, and the event will be published to the applications.[24]

Data sharing[編輯]

WinFS allows easy sharing of data between applications, and among multiple WinFS stores, which may reside on different computers, by copying to and from them.[30] A WinFS item can also be copied to a non-WinFS file system, but unless that data item is put back into the WinFS store, it will not support the advanced services provided by WinFS.

The WinFS API also provides some support for sharing with non-WinFS applications. WinFS exposes a shell object to access WinFS stores. This object maps WinFS items to a virtual folder hierarchy, and can be accessed by any application.[11] WinFS data can also be manually shared using network shares, by sharing the legacy shell object.[30] Non-WinFS file formats can be stored in WinFS stores, using the File Item, provided by WinFS. Importers can be written, to convert specific file formats to WinFS Item types.[30]

In addition, WinFS provides services to automatically synchronize items in two or more WinFS stores, subject to some predefined condition, such as "share only photos" or "share photos which have an associated contact X".[30] The stores may be on different computers. Synchronization is done in a peer-to-peer fashion; there is no central authority. A synchronization can be either manual or automatic or scheduled. During synchronization, WinFS finds the new and modified Items, and updates accordingly. If two or more changes conflict, WinFS can either resort to automatic resolution based on predefined rules, or defer the synchronization for manual resolution. WinFS also updates the schemas, if required.[30]

Application support[編輯]

Shell namespace[編輯]

WinFS Beta 1 includes a shell namespace extension, which surfaces WinFS stores as top level objects in My Computer view.[11] Files can be copied into and out of the stores, as well as applications can be directly used to save there. Even folders such as My Documents can be redirected to the stores.[11] WinFS uses Importer plug-ins to analyze the files as they were being imported to the store and create proper WinFS schemas and objects, and when taking the objects out, re-pack them into files.[30] If importers for certain files are not installed, they are stored as generic File types.

Microsoft Rave[編輯]

Microsoft Rave is an application that shipped with WinFS Beta 1. It allows synchronization of two or more WinFS stores. It supports synchronization in full mesh mode as well as the central hub topology. While synchronizing, Microsoft Rave will determine the changes made to each store since the last sync, and update accordingly. When applying the changes, it also detects if there is any conflict, i.e., the same data has been changed on both stores since the last synchronization. It will either log the conflicting data for later resolution or have it resolved immediately. Microsoft Rave uses peer-to-peer technology to communicate and transfer data.

StoreSpy[編輯]

檔案:Storespy.jpg
WinFS included StoreSpy, a WinFS Item browser that could be used to browse structured data instances with their properties and relationships.

With WinFS Beta 1, Microsoft included an unsupported application called StoreSpy,[31] which allowed one to browse WinFS stores by presenting a hierarchical view of WinFS Items. It automatically generated virtual folders based on access permissions, date and other metadata, and presented them in a hierarchical tree view, akin to what traditional folders are presented in. The application generated tabs for different Item types. StoreSpy allowed viewing Items, Relationships, MultiSet, Nested Elements, Extensions[32] and other types in the store along with its full metadata. It also presented a search interface to perform manual searches, and save them as virtual folders. The application also presented a graphical view of WinFS Rules. However, it did not allow editing of Items or their properties, though it was slated for inclusion in a future release.[33] But the WinFS project was cut back before it could materialize.

Type Browser[編輯]

WinFS also includes another application, named WinFS Type Browser, which can be used to browse the WinFS types, as well as visualize the hierarchical relationship between WinFS types.[34] A WinFS type, both built-in types as well as custom schemas, can be visualized along with all the properties and methods that it supports. It also shows the types that it derives from as well as other types that extend the type schema. However, while it was included with WinFS, it was released as an unsupported tool.[34]

OPather[編輯]

WinFS Beta 1 also includes an unsupported application, named OPather.[35] It presents a graphical interface for writing Opath queries. It can be used by selecting target object type and specifying the parameters of the query. It also includes Intellisense-like parameter completion feature. It can then be used to perform visualization tasks like binding results of a query to a DataGrid control, create views of the data in WinFS itself, or just extract the query string.

Project "Orange"[編輯]

Microsoft launched a project to build a data visualization application for WinFS. It was codenamed "Project Orange" and was supposedly built using Windows Presentation Foundation[36] It was supposed to provide exploration of Items stored in WinFS stores, and data relationships were supposed to be a prominent part of the navigation model. It was supposed to let people allow organization of the WinFS stores graphically as well - productizing many of the concepts shown in the IWish Concept Video。However, since the WinFS project went dark, the status of this project is unknown.

參考文獻[編輯]

模板:Reflist

另請參閱[編輯]

外部連結[編輯]

模板:MSNav

ar:وين إف إس cs:WinFS da:WinFS it:WinFS ja:WinFS ko:WinFS no:WinFS pt:WinFS

sv:WinFS