DBMS 數(shù)據(jù)庫(kù)管理系統(tǒng)的三級(jí)模式架構(gòu)《ClickHouse 實(shí)戰(zhàn):企業(yè)級(jí)大數(shù)據(jù)分析引擎》

引文

計(jì)算機(jī)科學(xué)領(lǐng)域的所有問(wèn)題浓恳,都可以通過(guò)添加一層中間層來(lái)解決什燕。通過(guò)在用戶(hù)和計(jì)算機(jī)中間添加一層邏輯層(概念模型層),于是就有了“數(shù)據(jù)庫(kù)的三級(jí)模式”:數(shù)據(jù)庫(kù)在三個(gè)級(jí)別 (層次)上進(jìn)行抽象舱痘,使用戶(hù)能夠邏輯地钓觉、抽象地處理數(shù)據(jù)派殷,而不必關(guān)心數(shù)據(jù)在計(jì)算機(jī)中的物理表示和存儲(chǔ)。 光劍墓阀,2021.

數(shù)據(jù)庫(kù)簡(jiǎn)介

當(dāng)今世界是一個(gè)充滿著數(shù)據(jù)的互聯(lián)網(wǎng)世界毡惜,充斥著大量的數(shù)據(jù)。即這個(gè)互聯(lián)網(wǎng)世界就是數(shù)據(jù)世界斯撮。數(shù)據(jù)的來(lái)源有很多经伙,比如出行記錄、消費(fèi)記錄勿锅、瀏覽的網(wǎng)頁(yè)帕膜、發(fā)送的消息等等。除了文本類(lèi)型的數(shù)據(jù)溢十,圖像垮刹、音樂(lè)、聲音都是數(shù)據(jù)张弛。

數(shù)據(jù)庫(kù)是一個(gè)按數(shù)據(jù)結(jié)構(gòu)來(lái)存儲(chǔ)和管理數(shù)據(jù)的計(jì)算機(jī)軟件系統(tǒng)荒典。數(shù)據(jù)庫(kù)的概念實(shí)際包括兩層意思:

(1)數(shù)據(jù)庫(kù)是一個(gè)實(shí)體,它是能夠合理保管數(shù)據(jù)的“倉(cāng)庫(kù)”吞鸭,用戶(hù)在該“倉(cāng)庫(kù)”中存放要管理的事務(wù)數(shù)據(jù)寺董,“數(shù)據(jù)”和“庫(kù)”兩個(gè)概念結(jié)合成為數(shù)據(jù)庫(kù)。

(2)數(shù)據(jù)庫(kù)是數(shù)據(jù)管理的新方法和技術(shù)刻剥,它能更合適的組織數(shù)據(jù)遮咖、更方便的維護(hù)數(shù)據(jù)、更嚴(yán)密的控制數(shù)據(jù)和更有效的利用數(shù)據(jù)造虏。

數(shù)據(jù)庫(kù)是“按照數(shù)據(jù)結(jié)構(gòu)來(lái)組織御吞、存儲(chǔ)和管理數(shù)據(jù)的倉(cāng)庫(kù)”麦箍。是一個(gè)長(zhǎng)期存儲(chǔ)在計(jì)算機(jī)內(nèi)的、有組織的魄藕、可共享的内列、統(tǒng)一管理的大量數(shù)據(jù)的集合。

數(shù)據(jù)庫(kù)是存放數(shù)據(jù)的倉(cāng)庫(kù)背率。它的存儲(chǔ)空間很大话瞧,可以存放百萬(wàn)條、千萬(wàn)條寝姿、上億條數(shù)據(jù)交排。但是數(shù)據(jù)庫(kù)并不是隨意地將數(shù)據(jù)進(jìn)行存放,是有一定的規(guī)則的饵筑,否則查詢(xún)的效率會(huì)很低埃篓。

數(shù)據(jù)庫(kù)發(fā)展歷史

數(shù)據(jù)庫(kù)的演變

數(shù)據(jù)建模和數(shù)據(jù)庫(kù)一起發(fā)展,它們的歷史可以追溯到 1960 年代根资。

數(shù)據(jù)庫(kù)演變發(fā)生在五個(gè)“浪潮”中:

1.第一波由網(wǎng)絡(luò)架专、分層、倒排列表和(在 1990 年代)面向?qū)ο蟮?DBMS 組成玄帕;它大約發(fā)生在 1960 年至 1999 年之間部脚。

2.關(guān)系浪潮在 1990 年左右推出了所有 SQL 產(chǎn)品(以及一些非 SQL),并在 2008 年左右開(kāi)始失去用戶(hù)裤纹。

3.決策支持浪潮在 1990 年左右引入了在線分析處理 (OLAP) 和專(zhuān)門(mén)的 DBMS委刘,并且今天仍然有效。

4.圖浪潮始于 1999 年萬(wàn)維網(wǎng)聯(lián)盟的語(yǔ)義網(wǎng)絡(luò)堆棧鹰椒,2008 年左右出現(xiàn)了屬性圖

5.NoSQL 浪潮包括大數(shù)據(jù)等等锡移;它始于2008年。


1973 年:查爾斯·巴赫曼 (Charles Bachman) 的“作為導(dǎo)航員的程序員”

1981 年:E.F. (Ted) Codd : “關(guān)系數(shù)據(jù)庫(kù):生產(chǎn)力的實(shí)用基礎(chǔ)”

2001 年:Ole-Johan Dahl 和 Kristen Nygaard 提出了面向?qū)ο缶幊?/i>出現(xiàn)的基本思想

2014 年:Michael Stonebraker 的 “The Land Sharkx are on the Squawk Box”漆际。

1973: Charles Bachman with “The Programmer as Navigator”

1981: E. F. (Ted) Codd with “Relational Database: A Practical Foundation for Productivity”

2001: Ole-Johan Dahl and Kristen Nygaard for ideas fundamental to the emergence of object-oriented programming

2014: Michael Stonebraker with “The Land Sharkx are on the Squawk Box.”

在數(shù)據(jù)庫(kù)的發(fā)展歷史上淆珊,數(shù)據(jù)庫(kù)先后經(jīng)歷了:?

1.層次數(shù)據(jù)庫(kù)

2.網(wǎng)狀數(shù)據(jù)庫(kù)

3.關(guān)系數(shù)據(jù)庫(kù)

等階段。隨著云計(jì)算的發(fā)展和大數(shù)據(jù)時(shí)代的到來(lái)灿椅,關(guān)系型數(shù)據(jù)庫(kù)越來(lái)越無(wú)法滿足需要套蒂,這主要是由于,越來(lái)越多的半關(guān)系型和非關(guān)系型數(shù)據(jù)茫蛹,需要用數(shù)據(jù)庫(kù)進(jìn)行存儲(chǔ)管理操刀。以此同時(shí),分布式技術(shù)等新技術(shù)的出現(xiàn)也對(duì)數(shù)據(jù)庫(kù)的技術(shù)提出了新的要求婴洼。


于是越來(lái)越多的非關(guān)系型數(shù)據(jù)庫(kù)就開(kāi)始出現(xiàn)骨坑,這類(lèi)數(shù)據(jù)庫(kù)與傳統(tǒng)的關(guān)系型數(shù)據(jù)庫(kù)在設(shè)計(jì)和數(shù)據(jù)結(jié)構(gòu)有了很大的不同, 它們更強(qiáng)調(diào)數(shù)據(jù)庫(kù)數(shù)據(jù)的高并發(fā)讀寫(xiě)和存儲(chǔ)大數(shù)據(jù),這類(lèi)數(shù)據(jù)庫(kù)一般被稱(chēng)為NoSQL(Not only SQL)數(shù)據(jù)庫(kù)欢唾。 而傳統(tǒng)的關(guān)系型數(shù)據(jù)庫(kù)在一些傳統(tǒng)領(lǐng)域依然保持了強(qiáng)大的生命力且警。

關(guān)系數(shù)據(jù)庫(kù)

關(guān)系型數(shù)據(jù)庫(kù),存儲(chǔ)的格式可以直觀地反映實(shí)體間的關(guān)系礁遣。關(guān)系型數(shù)據(jù)庫(kù)和常見(jiàn)的表格比較相似斑芜,關(guān)系型數(shù)據(jù)庫(kù)中表與表之間是有很多復(fù)雜的關(guān)聯(lián)關(guān)系的。 常見(jiàn)的關(guān)系型數(shù)據(jù)庫(kù)有Mysql祟霍,SqlServer等杏头。在輕量或者小型的應(yīng)用中,使用不同的關(guān)系型數(shù)據(jù)庫(kù)對(duì)系統(tǒng)的性能影響不大沸呐,但是在構(gòu)建大型應(yīng)用時(shí)醇王,則需要根據(jù)應(yīng)用的業(yè)務(wù)需求和性能需求,選擇合適的關(guān)系型數(shù)據(jù)庫(kù)崭添。

標(biāo)準(zhǔn)SQL語(yǔ)句

雖然關(guān)系型數(shù)據(jù)庫(kù)有很多寓娩,但是大多數(shù)都遵循SQL(結(jié)構(gòu)化查詢(xún)語(yǔ)言,Structured Query Language)標(biāo)準(zhǔn)呼渣。 常見(jiàn)的操作有查詢(xún)棘伴,新增,更新屁置,刪除排嫌,求和,排序等缰犁。

查詢(xún)語(yǔ)句:SELECT param FROM table WHERE condition 該語(yǔ)句可以理解為從 table 中查詢(xún)出滿足 condition 條件的字段 param。

新增語(yǔ)句:INSERT INTO table (param1怖糊,param2帅容,param3) VALUES (value1,value2伍伤,value3) 該語(yǔ)句可以理解為向table中的param1并徘,param2,param3字段中分別插入value1扰魂,value2麦乞,value3。

更新語(yǔ)句:UPDATE table SET param=new_value WHERE condition 該語(yǔ)句可以理解為將滿足condition條件的字段param更新為 new_value 值劝评。

刪除語(yǔ)句:DELETE FROM table WHERE condition 該語(yǔ)句可以理解為將滿足condition條件的數(shù)據(jù)全部刪除姐直。

去重查詢(xún):SELECT DISTINCT param FROM table WHERE condition 該語(yǔ)句可以理解為從表table中查詢(xún)出滿足條件condition的字段param,但是param中重復(fù)的值只能出現(xiàn)一次蒋畜。

排序查詢(xún):SELECT param FROM table WHERE condition ORDER BY param1該語(yǔ)句可以理解為從表table 中查詢(xún)出滿足condition條件的param声畏,并且要按照param1升序的順序進(jìn)行排序。

總體來(lái)說(shuō), 數(shù)據(jù)庫(kù)的SELECT插龄,INSERT愿棋,UPDATE,DELETE對(duì)應(yīng)了我們常用的增刪改查四種操作均牢。

關(guān)系型數(shù)據(jù)庫(kù)對(duì)于結(jié)構(gòu)化數(shù)據(jù)的處理更合適糠雨,如學(xué)生成績(jī)、地址等徘跪,這樣的數(shù)據(jù)一般情況下需要使用結(jié)構(gòu)化的查詢(xún)甘邀,例如join,這樣的情況下真椿,關(guān)系型數(shù)據(jù)庫(kù)就會(huì)比NoSQL數(shù)據(jù)庫(kù)性能更優(yōu)鹃答,而且精確度更高。由于結(jié)構(gòu)化數(shù)據(jù)的規(guī)模不算太大突硝,數(shù)據(jù)規(guī)模的增長(zhǎng)通常也是可預(yù)期的测摔,所以針對(duì)結(jié)構(gòu)化數(shù)據(jù)使用關(guān)系型數(shù)據(jù)庫(kù)更好。關(guān)系型數(shù)據(jù)庫(kù)十分注意數(shù)據(jù)操作的事務(wù)性解恰、一致性锋八,如果對(duì)這方面的要求關(guān)系型數(shù)據(jù)庫(kù)無(wú)疑可以很好的滿足。

非關(guān)系型數(shù)據(jù)庫(kù)(NoSQL)


隨著近些年技術(shù)方向的不斷拓展护盈,大量的NoSql數(shù)據(jù)庫(kù)如MongoDB挟纱、Redis、Memcache出于簡(jiǎn)化數(shù)據(jù)庫(kù)結(jié)構(gòu)腐宋、避免冗余紊服、影響性能的表連接、摒棄復(fù)雜分布式的目的被設(shè)計(jì)胸竞。

NoSQL 指分布式的欺嗤、非關(guān)系型的、不保證遵循ACID原則的數(shù)據(jù)存儲(chǔ)系統(tǒng)卫枝。

NoSQL數(shù)據(jù)庫(kù)技術(shù)與CAP理論煎饼、一致性哈希算法有密切關(guān)系。

所謂CAP理論校赤,簡(jiǎn)單來(lái)說(shuō)就是一個(gè)分布式系統(tǒng)不可能滿足可用性吆玖、一致性與分區(qū)容錯(cuò)性這三個(gè)要求,一次性滿足兩種要求是該系統(tǒng)的上限马篮。

一致性哈希算法則指的是NoSQL數(shù)據(jù)庫(kù)在應(yīng)用過(guò)程中沾乘,為滿足工作需求而在通常情況下產(chǎn)生的一種數(shù)據(jù)算法,該算法能有效解決工作方面的諸多問(wèn)題但也存在弊端积蔚,即工作完成質(zhì)量會(huì)隨著節(jié)點(diǎn)的變化而產(chǎn)生波動(dòng)意鲸,當(dāng)節(jié)點(diǎn)過(guò)多時(shí),相關(guān)工作結(jié)果就無(wú)法那么準(zhǔn)確。這一問(wèn)題使整個(gè)系統(tǒng)的工作效率受到影響怎顾,導(dǎo)致整個(gè)數(shù)據(jù)庫(kù)系統(tǒng)的數(shù)據(jù)亂碼與出錯(cuò)率大大提高读慎,甚至?xí)霈F(xiàn)數(shù)據(jù)節(jié)點(diǎn)的內(nèi)容遷移,產(chǎn)生錯(cuò)誤的代碼信息槐雾。

但盡管如此夭委,NoSQL數(shù)據(jù)庫(kù)技術(shù)還是具有非常明顯的應(yīng)用優(yōu)勢(shì),如數(shù)據(jù)庫(kù)結(jié)構(gòu)相對(duì)簡(jiǎn)單募强,在大數(shù)據(jù)量下的讀寫(xiě)性能好株灸;能滿足隨時(shí)存儲(chǔ)自定義數(shù)據(jù)格式需求,非常適用于大數(shù)據(jù)處理工作擎值。

NoSQL數(shù)據(jù)庫(kù)適合追求速度和可擴(kuò)展性慌烧、業(yè)務(wù)多變的應(yīng)用場(chǎng)景。

對(duì)于非結(jié)構(gòu)化數(shù)據(jù)的處理更合適鸠儿,如文章屹蚊、評(píng)論。這些數(shù)據(jù)通常只用于模糊處理(全文搜索进每、機(jī)器學(xué)習(xí))汹粤,并不需要像結(jié)構(gòu)化數(shù)據(jù)一樣,進(jìn)行精確查詢(xún)田晚。而且這類(lèi)數(shù)據(jù)的數(shù)據(jù)規(guī)模往往是海量的嘱兼,數(shù)據(jù)規(guī)模的增長(zhǎng)往往也是不可能預(yù)期的 —— 而NoSQL數(shù)據(jù)庫(kù)的擴(kuò)展能力幾乎也是無(wú)限的,所以NoSQL數(shù)據(jù)庫(kù)可以很好的滿足這一類(lèi)數(shù)據(jù)的存儲(chǔ)贤徒。NoSQL數(shù)據(jù)庫(kù)利用key-value可以大量的獲取大量的非結(jié)構(gòu)化數(shù)據(jù)芹壕,并且數(shù)據(jù)的獲取效率很高,但用它查詢(xún)結(jié)構(gòu)化數(shù)據(jù)效果就比較差接奈。

目前NoSQL數(shù)據(jù)庫(kù)仍然沒(méi)有一個(gè)統(tǒng)一的標(biāo)準(zhǔn)哪雕,它現(xiàn)在有四種大的分類(lèi):

(1)鍵值對(duì)存儲(chǔ)(key-value):代表軟件Redis,它的優(yōu)點(diǎn)能夠進(jìn)行數(shù)據(jù)的快速查詢(xún)鲫趁,而缺點(diǎn)是需要存儲(chǔ)數(shù)據(jù)之間的關(guān)系。

(2)列存儲(chǔ):代表軟件Hbase利虫,它的優(yōu)點(diǎn)是對(duì)數(shù)據(jù)能快速查詢(xún)挨厚,數(shù)據(jù)存儲(chǔ)的擴(kuò)展性強(qiáng)。而缺點(diǎn)是數(shù)據(jù)庫(kù)的功能有局限性糠惫。ClickHouse 也是列存儲(chǔ)疫剃。

(3)文檔數(shù)據(jù)庫(kù)存儲(chǔ):代表軟件MongoDB,它的優(yōu)點(diǎn)是對(duì)數(shù)據(jù)結(jié)構(gòu)要求不特別的嚴(yán)格硼讽。而缺點(diǎn)是查詢(xún)性的性能不好巢价,同時(shí)缺少一種統(tǒng)一查詢(xún)語(yǔ)言。

(4)圖形數(shù)據(jù)庫(kù)存儲(chǔ):代表軟件InfoGrid,它的優(yōu)點(diǎn)可以方便的利用圖結(jié)構(gòu)相關(guān)算法進(jìn)行計(jì)算壤躲。而缺點(diǎn)是要想得到結(jié)果必須進(jìn)行整個(gè)圖的計(jì)算城菊,而且遇到不適合的數(shù)據(jù)模型時(shí),圖形數(shù)據(jù)庫(kù)很難使用碉克。

數(shù)據(jù)庫(kù)管理系統(tǒng):Database Management System

數(shù)據(jù)庫(kù)管理系統(tǒng)(DBMS凌唬,Database Management System)是操縱和管理數(shù)據(jù)庫(kù)的大型軟件,用于建立漏麦、使用和維護(hù)數(shù)據(jù)庫(kù)客税,簡(jiǎn)稱(chēng)DBMS。它對(duì)數(shù)據(jù)庫(kù)進(jìn)行統(tǒng)一的管理和控制撕贞,以保證數(shù)據(jù)庫(kù)的安全性和完整性更耻。大部分DBMS提供數(shù)據(jù)定義語(yǔ)言DDL(Data Definition Language)和數(shù)據(jù)操作語(yǔ)言DML(Data Manipulation Language),供用戶(hù)定義數(shù)據(jù)庫(kù)的模式結(jié)構(gòu)與權(quán)限約束捏膨,實(shí)現(xiàn)對(duì)數(shù)據(jù)的追加秧均、刪除等操作。

SQL 數(shù)據(jù)庫(kù)管理軟件

MySQL:最流行的開(kāi)源數(shù)據(jù)庫(kù),它是基于 Web 的應(yīng)用程序的領(lǐng)先解決方案楞慈,因?yàn)樗С?SQL 作為其數(shù)據(jù)庫(kù)語(yǔ)言并包含與 SQL 查詢(xún)相關(guān)的視圖嚎京,從而可以查看數(shù)據(jù)庫(kù)的特定部分.

Oracle RDBMS:領(lǐng)先的全球關(guān)系數(shù)據(jù)庫(kù)管理系統(tǒng),它實(shí)現(xiàn)了面向?qū)ο蟮奶匦匝纫缬脩?hù)定義的類(lèi)型、繼承和多態(tài)久又。

PostgreSQL:對(duì)象關(guān)系數(shù)據(jù)庫(kù)系統(tǒng)巫延,可在所有主要操作系統(tǒng)上運(yùn)行,并允許需要關(guān)系數(shù)據(jù)庫(kù)的內(nèi)部或商業(yè) Web 開(kāi)發(fā)地消。它包括一個(gè)關(guān)系系統(tǒng)目錄炉峰,該目錄支持每個(gè)數(shù)據(jù)庫(kù)的多個(gè)模式。

MS SQL:Microsoft 開(kāi)發(fā)的關(guān)系數(shù)據(jù)庫(kù)管理系統(tǒng)脉执,可根據(jù)其他軟件應(yīng)用程序的要求存儲(chǔ)和檢索數(shù)據(jù)疼阔。

MariaDB:由原始 MySQL 開(kāi)發(fā)人員制作的流行數(shù)據(jù)庫(kù)服務(wù)器,可將數(shù)據(jù)轉(zhuǎn)換為各種應(yīng)用程序中的結(jié)構(gòu)化信息半夷。MariaDB 具有快速婆廊、可擴(kuò)展和強(qiáng)大的存儲(chǔ)引擎、插件和其他工具組合巫橄,旨在提供 SQL 接口來(lái)訪問(wèn)數(shù)據(jù)淘邻。

SQLite:廣泛使用的 C 語(yǔ)言庫(kù),它實(shí)現(xiàn)了 SQL 數(shù)據(jù)庫(kù)引擎湘换,內(nèi)置于所有手機(jī)和大多數(shù)計(jì)算機(jī)中宾舅。

DATAPINE:幫助用戶(hù)探索统阿、可視化和共享數(shù)據(jù)的商業(yè)智能軟件。它有助于從多個(gè)現(xiàn)有數(shù)據(jù)庫(kù)筹我、外部應(yīng)用程序和 Excel 數(shù)據(jù)創(chuàng)建數(shù)據(jù)庫(kù)扶平。

DbVisualizer:適用于所有主要數(shù)據(jù)庫(kù)的數(shù)據(jù)庫(kù)管理和分析工具。借助拖放功能崎溃,它可以促進(jìn)數(shù)據(jù)庫(kù)的開(kāi)發(fā)蜻直、分析和管理。

RazorSQL:適用于 Windows macOS袁串、Mac OS X概而、Linux 和 Solaris 的 SQL 編輯器、SQL 查詢(xún)工具囱修、數(shù)據(jù)庫(kù)查詢(xún)工具和數(shù)據(jù)庫(kù)管理工具赎瑰,使用戶(hù)能夠?yàn)g覽數(shù)據(jù)庫(kù)對(duì)象并管理數(shù)據(jù)庫(kù)。

NoSQL 數(shù)據(jù)庫(kù)管理軟件

Redis:開(kāi)源的內(nèi)存數(shù)據(jù)結(jié)構(gòu)存儲(chǔ)破镰,用作數(shù)據(jù)庫(kù)餐曼、緩存和消息代理,支持字符串鲜漩、哈希源譬、列表、集合孕似、位圖踩娘、地理空間索引、流等數(shù)據(jù)結(jié)構(gòu)喉祭。

MongoDB:文檔數(shù)據(jù)庫(kù)养渴,將數(shù)據(jù)存儲(chǔ)在靈活的類(lèi)似 JSON 的文檔中,以映射對(duì)象并簡(jiǎn)化數(shù)據(jù)管理泛烙。它的核心是一個(gè)具有高可用性理卑、水平擴(kuò)展和地理分布的分布式數(shù)據(jù)庫(kù)。

GraphQL:用于 API 的開(kāi)源查詢(xún)和操作語(yǔ)言蔽氨,還可用作運(yùn)行時(shí)以使用現(xiàn)有數(shù)據(jù)填充查詢(xún)藐唠。

Apache CouchDB:開(kāi)源數(shù)據(jù)庫(kù)軟件,側(cè)重于面向文檔的 NoSQL 的易用性和可擴(kuò)展架構(gòu)鹉究。它使用 JSON 存儲(chǔ)數(shù)據(jù)中捆,使用 JavaScript 作為查詢(xún)語(yǔ)言,使用 HTTP 作為 API坊饶。

Neo4j:用于任務(wù)關(guān)鍵型企業(yè)應(yīng)用程序的圖形數(shù)據(jù)庫(kù)管理平臺(tái)。它被認(rèn)為是最流行的圖形事務(wù)數(shù)據(jù)庫(kù)之一殴蓬,具有本機(jī)存儲(chǔ)和處理功能匿级。

內(nèi)存數(shù)據(jù)庫(kù)管理系統(tǒng)?

Apache Ignite:開(kāi)源分布式數(shù)據(jù)庫(kù)蟋滴、緩存和處理平臺(tái),可跨節(jié)點(diǎn)集群存儲(chǔ)和計(jì)算大量數(shù)據(jù)痘绎。

Memcached:分布式內(nèi)存緩存系統(tǒng)津函,用于加速動(dòng)態(tài)數(shù)據(jù)庫(kù)驅(qū)動(dòng)的網(wǎng)站,將數(shù)據(jù)和對(duì)象緩存在 RAM 中孤页。

基于云的數(shù)據(jù)管理系統(tǒng)

Amazon Relational Database:使用戶(hù)能夠在云中設(shè)置尔苦、操作和擴(kuò)展關(guān)系數(shù)據(jù)庫(kù)的 Web 服務(wù)。

Microsoft Azure SQL 數(shù)據(jù)庫(kù):支持關(guān)系數(shù)據(jù)行施、JSON允坚、空間和 XML 等結(jié)構(gòu)的關(guān)系數(shù)據(jù)庫(kù)即服務(wù)。

Rackspace 云:云計(jì)算產(chǎn)品和服務(wù)的集合蛾号,例如 Web 應(yīng)用程序托管稠项、平臺(tái)即服務(wù)、云存儲(chǔ)鲜结、虛擬專(zhuān)用服務(wù)器展运、負(fù)載平衡器、數(shù)據(jù)庫(kù)精刷、備份拗胜、監(jiān)控等。

SAP Cloud 平臺(tái):開(kāi)放式平臺(tái)即服務(wù)怒允,提供獨(dú)特的內(nèi)存數(shù)據(jù)庫(kù)和業(yè)務(wù)應(yīng)用程序服務(wù)埂软,為數(shù)字企業(yè)提供支持。

數(shù)據(jù)庫(kù)管理的挑戰(zhàn)

數(shù)據(jù)庫(kù)管理中一些最顯著的挑戰(zhàn)是:

維護(hù) DBMS 解決方案的硬件和軟件的高成本误算。

DBMS 很復(fù)雜仰美,因此需要培訓(xùn)和專(zhuān)門(mén)的內(nèi)部經(jīng)驗(yàn)資源。

由于數(shù)據(jù)庫(kù)管理系統(tǒng)提供集中式解決方案儿礼,任何故障或數(shù)據(jù)損壞都可能影響整個(gè)數(shù)據(jù)庫(kù)咖杂。

如果多個(gè)用戶(hù)同時(shí)訪問(wèn)同一個(gè)程序,則存在數(shù)據(jù)丟失的風(fēng)險(xiǎn)蚊夫。

在 DBMS 故障期間诉字,可能會(huì)因忽視維護(hù)系統(tǒng)的最佳功能而招致重大損失。

如果數(shù)據(jù)庫(kù)存儲(chǔ)大量數(shù)據(jù)知纷,性能可能會(huì)受到影響壤圃。

小結(jié):數(shù)據(jù)不會(huì)消失。在數(shù)據(jù)驅(qū)動(dòng)的世界中琅轧,企業(yè)需要有效處理和管理數(shù)據(jù):能夠從數(shù)據(jù)存儲(chǔ)伍绳、數(shù)據(jù)組織、數(shù)據(jù)檢索乍桂、數(shù)據(jù)分析等全方位管理數(shù)據(jù)冲杀。DBMS 使企業(yè)能夠?qū)?shù)據(jù)進(jìn)行排序效床、過(guò)濾、發(fā)現(xiàn)权谁、定位剩檀、學(xué)習(xí)和更新,以從客戶(hù)那里獲取關(guān)鍵信息旺芽,并分析其他關(guān)鍵業(yè)務(wù)活動(dòng)并在決策中實(shí)施這些知識(shí)沪猴。?

DBMS系統(tǒng)的7大功能

1.數(shù)據(jù)定義DBMS提供數(shù)據(jù)定義語(yǔ)言DDL(Data Definition Language),供用戶(hù)定義數(shù)據(jù)庫(kù)的三級(jí)模式結(jié)構(gòu)采章、兩級(jí)映像以及完整性約束和保密限制等約束运嗜。DDL主要用于建立、修改數(shù)據(jù)庫(kù)的庫(kù)結(jié)構(gòu)共缕。DDL所描述的庫(kù)結(jié)構(gòu)僅僅給出了數(shù)據(jù)庫(kù)的框架洗出,數(shù)據(jù)庫(kù)的框架信息被存放在數(shù)據(jù)字典(Data Dictionary)中。?

2.數(shù)據(jù)操作:DBMS提供數(shù)據(jù)操作語(yǔ)言DML(Data Manipulation Language)图谷,供用戶(hù)實(shí)現(xiàn)對(duì)數(shù)據(jù)的追加翩活、刪除、更新便贵、查詢(xún)等操作菠镇。?

3.數(shù)據(jù)庫(kù)的運(yùn)行管理:數(shù)據(jù)庫(kù)的運(yùn)行管理功能是DBMS的運(yùn)行控制、管理功能承璃,包括多用戶(hù)環(huán)境下的并發(fā)控制利耍、安全性檢查和存取限制控制、完整性檢查和執(zhí)行盔粹、運(yùn)行日志的組織管理隘梨、事務(wù)的管理和自動(dòng)恢復(fù),即保證事務(wù)的原子性舷嗡。這些功能保證了數(shù)據(jù)庫(kù)系統(tǒng)的正常運(yùn)行轴猎。?

4.數(shù)據(jù)組織、存儲(chǔ)與管理:DBMS要分類(lèi)組織进萄、存儲(chǔ)和管理各種數(shù)據(jù)捻脖,包括數(shù)據(jù)字典、用戶(hù)數(shù)據(jù)中鼠、存取路徑等可婶,需確定以何種文件結(jié)構(gòu)和存取方式在存儲(chǔ)級(jí)上組織這些數(shù)據(jù),如何實(shí)現(xiàn)數(shù)據(jù)之間的聯(lián)系援雇。數(shù)據(jù)組織和存儲(chǔ)的基本目標(biāo)是提高存儲(chǔ)空間利用率矛渴,選擇合適的存取方法提高存取效率。?

5.數(shù)據(jù)庫(kù)的保護(hù):數(shù)據(jù)庫(kù)中的數(shù)據(jù)是信息社會(huì)的戰(zhàn)略資源惫搏,所以數(shù)據(jù)的保護(hù)至關(guān)重要具温。DBMS對(duì)數(shù)據(jù)庫(kù)的保護(hù)通過(guò)4個(gè)方面來(lái)實(shí)現(xiàn):數(shù)據(jù)庫(kù)的恢復(fù)盗舰、數(shù)據(jù)庫(kù)的并發(fā)控制、數(shù)據(jù)庫(kù)的完整性控制桂躏、數(shù)據(jù)庫(kù)安全性控制。DBMS的其他保護(hù)功能還有系統(tǒng)緩沖區(qū)的管理以及數(shù)據(jù)存儲(chǔ)的某些自適應(yīng)調(diào)節(jié)機(jī)制等川陆。?

6.數(shù)據(jù)庫(kù)的維護(hù):這一部分包括數(shù)據(jù)庫(kù)的數(shù)據(jù)載入剂习、轉(zhuǎn)換、轉(zhuǎn)儲(chǔ)较沪、數(shù)據(jù)庫(kù)的重組合重構(gòu)以及性能監(jiān)控等功能鳞绕,這些功能分別由各個(gè)使用程序來(lái)完成。?

7.通信:DBMS具有與操作系統(tǒng)的聯(lián)機(jī)處理尸曼、分時(shí)系統(tǒng)及遠(yuǎn)程作業(yè)輸入的相關(guān)接口们何,負(fù)責(zé)處理數(shù)據(jù)的傳送。對(duì)網(wǎng)絡(luò)環(huán)境下的數(shù)據(jù)庫(kù)系統(tǒng)控轿,還應(yīng)該包括DBMS與網(wǎng)絡(luò)中其他軟件系統(tǒng)的通信功能以及數(shù)據(jù)庫(kù)之間的互操作功能冤竹。

數(shù)據(jù)庫(kù)管理系統(tǒng)的三層模式架構(gòu):Three Level Architecture of DBMS

計(jì)算機(jī)科學(xué)領(lǐng)域的所有問(wèn)題,都可以通過(guò)添加一層中間層來(lái)解決茬射。通過(guò)在用戶(hù)和計(jì)算機(jī)中間添加一層邏輯層(概念模型層)鹦蠕,于是就有了“數(shù)據(jù)庫(kù)的三級(jí)模式”:數(shù)據(jù)庫(kù)在三個(gè)級(jí)別 (層次)上進(jìn)行抽象,使用戶(hù)能夠邏輯地在抛、抽象地處理數(shù)據(jù)钟病,而不必關(guān)心數(shù)據(jù)在計(jì)算機(jī)中的物理表示和存儲(chǔ)

BY? 光劍刚梭,2021.

例如肠阱,操作系統(tǒng)就是在用戶(hù)跟計(jì)算機(jī)硬件之間的抽象層。

操作系統(tǒng)(operating system朴读,簡(jiǎn)稱(chēng)OS)是管理計(jì)算機(jī)硬件軟件資源的計(jì)算機(jī)程序屹徘。操作系統(tǒng)需要處理如管理與配置內(nèi)存、決定系統(tǒng)資源供需的優(yōu)先次序磨德、控制輸入設(shè)備輸出設(shè)備缘回、操作網(wǎng)絡(luò)與管理文件系統(tǒng)等基本事務(wù)。操作系統(tǒng)也提供一個(gè)讓用戶(hù)與系統(tǒng)交互的操作界面典挑。

對(duì)于理想的層次式計(jì)算機(jī)系統(tǒng)體系結(jié)構(gòu)來(lái)說(shuō)酥宴,其之間的聯(lián)系不僅僅是單向依賴(lài)性的,同時(shí)各個(gè)層級(jí)之間也要具備相互的獨(dú)立性您觉,且只能對(duì)低層次的模塊和功能進(jìn)行調(diào)用

數(shù)據(jù)實(shí)際上以位拙寡、數(shù)字和字符串的形式存儲(chǔ),但是在這個(gè)級(jí)別處理數(shù)據(jù)的多樣性和復(fù)雜性是極其困難的琳水。

Data are actually stored as bits, or numbers and strings, but it is extremely difficult to work with the variety and complexity of data at this level.

名詞說(shuō)明 :Schema

This is the term for a description of the data organization at some level. Each level has its own schema.

這是在某種程度上描述數(shù)據(jù)組織的術(shù)語(yǔ)肆糕。每個(gè)級(jí)別都有自己的模式般堆。

We will be concerned with three forms of schemas:

1.external or user view

2.conceptual or logical

3.internal or physical


1. 外部數(shù)據(jù)層

外部模式,根據(jù)概念級(jí)別诚啃,指定數(shù)據(jù)視圖淮摔。為特定用戶(hù)需求量身定制。某些用戶(hù)不應(yīng)看到部分存儲(chǔ)數(shù)據(jù)始赎,權(quán)限&安全性控制和橙。

External Data Level

An external schema specifies aviewof the data in terms of the conceptual level. It is tailored to the needs of a particular category of users. Portions of stored data should not be seen by some users and begins to implement a level of security and simplifies the view for these users.

在關(guān)系模型中,外部模式也將數(shù)據(jù)表示為一組關(guān)系造垛。例子:

In the relational model, theexternal schemaalso presents data as a set of relations.

Examples:

學(xué)生不應(yīng)該看到教職員工的工資魔招。

教職員工不應(yīng)看到帳單或付款數(shù)據(jù)。

可以從存儲(chǔ)的數(shù)據(jù)中導(dǎo)出的信息可能被視為以這種方式存儲(chǔ)五辽。

GPA 不存儲(chǔ)办斑,需要時(shí)計(jì)算。

Students should not see faculty salaries.

Faculty should not see billing or payment data.

Information that can be derived from stored data might be viewed as if it were stored in that manner.

GPA not stored, calculated when needed.

應(yīng)用程序是根據(jù)外部模式編寫(xiě)的杆逗。訪問(wèn)時(shí)計(jì)算外部視圖乡翅。它不被存儲(chǔ)∷栌可以向不同類(lèi)別的用戶(hù)提供不同的外部模式峦朗。DBMS 在運(yùn)行時(shí),自動(dòng)完成從外部級(jí)別到概念級(jí)別的轉(zhuǎn)換排龄〔ㄊ疲可以在不更改應(yīng)用程序的情況下更改概念模式(改變從外部到概念的映射)——稱(chēng)之為“概念數(shù)據(jù)獨(dú)立性”。

Applications are written in terms of an external schema. The external view is computed when accessed.? It is not stored. Different external schemas can be provided to different categories of users. Translation from external level to conceptual level is done automatically by DBMS at run time. The conceptual schema can be changed without changing application:Mapping from external to conceptual must be changed. Referred to as?conceptual data independence.

This is a first level of security that can be imposed on the various users of the system.

這是系統(tǒng)第一級(jí)安全性橄维。

2. 概念數(shù)據(jù)層

當(dāng)概念級(jí)別實(shí)現(xiàn)到特定數(shù)據(jù)庫(kù)架構(gòu)時(shí)尺铣,也稱(chēng)為邏輯級(jí)別。

隱藏內(nèi)部/物理層的存儲(chǔ)細(xì)節(jié)争舞。

在關(guān)系模型中凛忿,概念模式將數(shù)據(jù)表示為一組表。

DBMS 自動(dòng)將邏輯模式之間的數(shù)據(jù)訪問(wèn)映射到內(nèi)部/物理模式竞川。

無(wú)需更改應(yīng)用程序即可更改物理/內(nèi)部架構(gòu):例如店溢,我們可以添加或刪除索引,DBMS 必須將映射從概念變?yōu)槲锢砦凇:?jiǎn)稱(chēng)物理數(shù)據(jù)獨(dú)立床牧。


我們將使用實(shí)體關(guān)系建模將邏輯視圖抽象為概念視圖,實(shí)體關(guān)系建模與數(shù)據(jù)庫(kù)架構(gòu)無(wú)關(guān)遭贸。

Conceptual Data Level

Also referred to as the?Logical?level when the conceptual level is implemented to a particular database architecture.

Hides storage details of the internal/physical level.

In the relational model, the conceptual schema presents data as a set of tables.

The DBMS automatically maps data access between the logical to internal/physical schemas .

Physical/internal schema can be changed without changing application: e.g. we may add or remove an index戈咳,DBMS must change mapping from conceptual to physical.

Referred to as?physical data independence.

We will abstract the logical view as a conceptual view using Entity-Relationship Modeling, which is database architecture independent.

3.內(nèi)部數(shù)據(jù)層

內(nèi)部層物理模式描述了數(shù)據(jù)如何存儲(chǔ)的細(xì)節(jié):隨機(jī)存取磁盤(pán)系統(tǒng)上的文件、索引等。它還通常描述文件的記錄布局和文件類(lèi)型(散列著蛙、b 樹(shù)删铃、平面等)。

早期的應(yīng)用程序(1960 年代)僅在此級(jí)別工作 - 明確處理這些內(nèi)部細(xì)節(jié)踏堡。例如猎唁,最小化相關(guān)數(shù)據(jù)之間的物理距離并組織文件內(nèi)的數(shù)據(jù)結(jié)構(gòu)(塊記錄、塊鏈表等)

問(wèn)題:

1.為了處理物理數(shù)據(jù)顷蟆,程序被硬編碼胖秒。

2.對(duì)數(shù)據(jù)結(jié)構(gòu)的更改很難進(jìn)行。

3.應(yīng)用程序代碼變得復(fù)雜慕的,因?yàn)樗仨毺幚砑?xì)節(jié)。

4.新功能的快速實(shí)施非常困難挤渔。

Internal Data Level

The?physical schema of the internal level?describes details of how data is stored: files, indices, etc. on the random access disk system.? It also typically describes the record layout of files and type of files (hash, b-tree, flat).

Early applications (1960's) only worked at this level - explicitly dealt with these internal details. E.g., minimizing physical distances between related data and organizing the data structures within the file (blocked records, linked lists of blocks, etc.)

Problem:

1.Routines are hardcoded to deal with physical representation.

2.Changes to data structures are difficult to make.

3.Application code becomes complex since it must deal with details.

4.Rapid implementation of new features very difficult.

數(shù)據(jù)建模

Schema?: 某種級(jí)別的數(shù)據(jù)描述(例如肮街,表、屬性判导、約束嫉父、域)

模型:用于描述的工具和語(yǔ)言:

由數(shù)據(jù)定義語(yǔ)言 (DDL) 描述的概念/邏輯和外部模式

完整性約束,DDL 描述的域

數(shù)據(jù)操作語(yǔ)言 (DML) 描述的數(shù)據(jù)操作

影響物理模式(影響性能眼刃,而不是語(yǔ)義)的指令由存儲(chǔ)定義語(yǔ)言 (SDL) 描述

Data Modeling

Schema: description of data at some level (e.g., tables, attributes, constraints, domains)

Model: tools and languages for describing:

Conceptual/logical and external schema described by the data definition language (DDL)

Integrity constraints, domains described by DDL

Operations on data described by the data manipulation language (DML)

Directives that influence the physical schema (affects performance, not semantics) are described by the storage definition language (SDL)


數(shù)據(jù)獨(dú)立


邏輯數(shù)據(jù)獨(dú)立

外部模型對(duì)邏輯模型變化的免疫力

發(fā)生在用戶(hù)界面級(jí)別

物理數(shù)據(jù)獨(dú)立性

邏輯模型對(duì)內(nèi)部模型變化的免疫力

發(fā)生在邏輯接口級(jí)別

Logical data independence

Immunity of external models to changes in the logical model

Occurs at user interface level

Physical data independence

Immunity of logical model to changes in internal model

Occurs at logical interface level

實(shí)體關(guān)系模型

語(yǔ)義模型捕獲含義和意圖

ER 建模是概念級(jí)模型

1970年代由PP Chen提出

實(shí)體是我們收集數(shù)據(jù)的現(xiàn)實(shí)世界對(duì)象

屬性進(jìn)一步描述具有特定值的實(shí)體

關(guān)系是實(shí)體之間的關(guān)聯(lián)

實(shí)體集——相同類(lèi)型的實(shí)體集

關(guān)系集——一組相同類(lèi)型的關(guān)系

關(guān)系集也可能具有描述性屬性

用ER圖表示

Entity-Relationship Model

A semantic model (語(yǔ)義模型)captures meanings and intents

E-R modeling is a?conceptual level?model

Proposed by P.P. Chen in 1970s

Entities?are real-world objects about which we collect data

Attributes?further describe the entities with particular values

Relationships?are associations among entities

Entity set?– set of entities of the same type

Relationship set?– set of relationships of same type

Relationships sets may also have descriptive attributes

Represented by E-R diagrams


關(guān)系模型

基于記錄和表的模型

關(guān)系數(shù)據(jù)庫(kù)建模是一種邏輯級(jí)模型

由 EF Codd 提出

基于數(shù)學(xué)關(guān)系

使用關(guān)系绕辖,表示為表格

表格的列代表屬性

表代表關(guān)系和實(shí)體

早期基于記錄的模型的繼承者——網(wǎng)絡(luò)和分層

Relational Model

Record and Table based model

Relational database modeling is a?logical-level?model

Proposed by E.F. Codd

Based on mathematical relations(關(guān)系代數(shù))

Uses relations, represented as tables

Columns of tables represent attributes

Tables represent relationships as well as entities

Successor to earlier record-based models—network and hierarchical


面向?qū)ο竽P?br>

使用 ER 建模作為基礎(chǔ),但擴(kuò)展到包括封裝擂红、繼承仪际。

對(duì)象既有狀態(tài)又有行為。

狀態(tài)由屬性定義

行為由方法(函數(shù)或過(guò)程)定義

設(shè)計(jì)器定義具有屬性昵骤、方法和關(guān)系的類(lèi)

類(lèi)構(gòu)造方法創(chuàng)建對(duì)象實(shí)例

每個(gè)對(duì)象都有一個(gè)唯一的對(duì)象 ID

類(lèi)層次結(jié)構(gòu)相關(guān)的類(lèi)

數(shù)據(jù)庫(kù)對(duì)象具有持久性

兩個(gè)概念上的級(jí)邏輯級(jí)模型

Object-oriented Model

Uses the E-R modeling as a basis but extended to include?encapsulation,?inheritance.

Objects have both state and behavior

State?is defined by attributes

Behavior?is defined by methods (functions or procedures)

Designer defines classes with attributes, methods, and relationships

Class constructor method creates object instances

Each object has a unique object ID

Classes related by class hierarchies

Database objects have persistence

Both?conceptual-level?and?logical-level model

對(duì)象關(guān)系模型

向關(guān)系模型添加新的復(fù)雜數(shù)據(jù)類(lèi)型

添加具有屬性和方法的對(duì)象

添加繼承

SQL 擴(kuò)展到處理 SQL:1999 中的對(duì)象


Object-relational model

Adds new complex datatypes to relational model

Adds objects with attributes and methods

Adds inheritance

SQL extended to handle objects in SQL:1999

半結(jié)構(gòu)化模型

節(jié)點(diǎn)的集合树碱,每個(gè)節(jié)點(diǎn)都有數(shù)據(jù)和不同的模式

每個(gè)節(jié)點(diǎn)都包含對(duì)其自身內(nèi)容的描述

可用于集成現(xiàn)有數(shù)據(jù)庫(kù)

添加到文檔的 XML 標(biāo)簽來(lái)描述結(jié)構(gòu)

XML 標(biāo)簽標(biāo)識(shí)文檔中的元素、子元素变秦、屬性

用于定義結(jié)構(gòu)的 XML DTD(文檔類(lèi)型定義)或 XML Schem

Semi-structured Model

Collection of nodes, each with data, and with different schemas

Each node contains a description of its own contents

Can be used for integrating existing databases

XML tags added to documents to describe structure

XML tags identify elements, sub-elements, attributes in documents

XML DTD (Document Type Definition) or XML Schema used to define structure

(Discussed later in the course in greater detail)

Phases of database design

Database designing for a real-world application starts from capturing the requirements to physical implementation using DBMS software which consists of following steps shown below:

Conceptual Design:?The requirements of database are captured using high level conceptual data model. For Example, the ER model is used for the conceptual design of the database.

Logical Design:?Logical Design represents data in the form of relational model. ER diagram produced in the conceptual design phase is used to convert the data into the Relational Model.

Physical Design:?In physical design, data in relational model is implemented using commercial DBMS like Oracle, DB2.

Advantages of DBMS

?DBMS helps in efficient organization of data in database which has following advantages over typical file system:

Minimized redundancy and data inconsistency:?Data is normalized in DBMS to minimize the redundancy which helps in keeping data consistent. For Example, student information can be kept at one place in DBMS and accessed by different users.This minimized redundancy is due to primary key and foreign keys

Simplified Data Access:?A user need only name of the relation not exact location to access data, so the process is very simple.

Multiple data views:?Different views of same data can be created to cater the needs of different users. For Example, faculty salary information can be hidden from student view of data but shown in admin view.

Data Security:?Only authorized users are allowed to access the data in DBMS. Also, data can be encrypted by DBMS which makes it secure.

Concurrent access to data:?Data can be accessed concurrently by different users at same time in DBMS.

Backup and Recovery mechanism:?DBMS backup and recovery mechanism helps to avoid data loss and data inconsistency in case of catastrophic failures.

關(guān)系代數(shù)

關(guān)系代數(shù)是一種抽象的查詢(xún)語(yǔ)言成榜,用對(duì)關(guān)系的運(yùn)算來(lái)表達(dá)查詢(xún),作為研究關(guān)系數(shù)據(jù)語(yǔ)言的數(shù)學(xué)工具蹦玫。

關(guān)系代數(shù)的運(yùn)算對(duì)象是關(guān)系赎婚,運(yùn)算結(jié)果亦為關(guān)系。

關(guān)系代數(shù)用到的運(yùn)算符包括四類(lèi):

1.集合運(yùn)算符

2.關(guān)系運(yùn)算符

3.算術(shù)比較符

4.邏輯運(yùn)算符

比較運(yùn)算符和邏輯運(yùn)算符樱溉,是用來(lái)輔助專(zhuān)門(mén)的關(guān)系運(yùn)算符進(jìn)行操作的挣输。

所以按照運(yùn)算符的不同,主要將關(guān)系代數(shù)分為傳統(tǒng)的集合運(yùn)算和專(zhuān)門(mén)的關(guān)系運(yùn)算兩類(lèi)饺窿。

集合運(yùn)算

傳統(tǒng)的集合運(yùn)算是二目運(yùn)算歧焦,包括并、交、差绢馍、廣義笛卡爾積四種運(yùn)算向瓷。

⒈ 并(Union)

設(shè)關(guān)系R和關(guān)系S具有相同的目n(即兩個(gè)關(guān)系都有n個(gè)屬性),且相應(yīng)的屬性取自同一個(gè)域舰涌,則關(guān)系R與關(guān)系S的并由屬于R且屬于S的元組組成猖任。其結(jié)果關(guān)系仍為n目關(guān)系。記作:

R∪S={t|t∈R∨t∈S}

⒉ 差(Difference)

設(shè)關(guān)系R和關(guān)系S具有相同的目n瓷耙,且相應(yīng)的屬性取自同一個(gè)域朱躺,則關(guān)系R與關(guān)系S的差由屬于R而不屬于S的所有元組組成。其結(jié)果關(guān)系仍為n目關(guān)系搁痛。記作:

R - S={t|t∈R∧t?S}

⒊ 交(Intersection Referential integrity)

設(shè)關(guān)系R和關(guān)系S具有相同的目n长搀,且相應(yīng)的屬性取自同一個(gè)域,則關(guān)系R與關(guān)系S的交由既屬于R又屬于S的元組組成鸡典。其結(jié)果關(guān)系仍為n目關(guān)系源请。記作:

R∩S={t|t∈R∧t∈S}

⒋ 廣義笛卡爾積(Extended cartesian product)

這里的笛卡爾積嚴(yán)格地講是廣義笛卡爾積(Extended Cartesian Product)。在不會(huì)出現(xiàn)混淆的情況下廣義笛卡爾積也稱(chēng)為笛卡爾積彻况。

兩個(gè)分別為n目和m目的關(guān)系R和S的廣義笛卡爾積是一個(gè)(n+m)列的元組的集合谁尸。元組的前n列是關(guān)系R的一個(gè)元組,后m列是關(guān)系S的一個(gè)元組纽甘。若R有k1個(gè)元組良蛮,S有k2個(gè)元組熄捍,則關(guān)系R和關(guān)系S的廣義笛卡爾積有k1×k2個(gè)元組弥鹦。

記作:

R×S={(t_r, t_s ) |t_r∈R芍瑞,t_s∈S}

專(zhuān)門(mén)的關(guān)系運(yùn)算

專(zhuān)門(mén)的關(guān)系運(yùn)算(Specific relation operations)包括:選擇左权、投影瞒斩、連接、除等涮总。

為了敘述上的方便胸囱,我們先引入幾個(gè)記號(hào)。

1. 設(shè)關(guān)系模式為 R(A1, A2, …, An)瀑梗。它的一個(gè)關(guān)系設(shè)為R烹笔。t∈R表示t是R的一個(gè)元組。t[Ai]則表示元組t中相應(yīng)于屬性Ai的一個(gè)分量 抛丽。

2. 若A={Ai1, Ai2, …, Aik}谤职,其中Ai1, Ai2, …, Aik是A1, A2, …, An中的一部分,則A稱(chēng)為屬性列或域列亿鲜。フA則表示{A1, A2, …, An}中去掉{Ai1, Ai2, …, Aik}后剩余的屬性組允蜈。t[A]=(t[Ai1], t[Ai2], …, t[Aik])表示元組t在屬性列A上諸分量的集合冤吨。

3. R為n目關(guān)系,S為m目關(guān)系饶套。設(shè)tr∈R(r為下標(biāo))漩蟆,ts∈S(s為下標(biāo)),則trts(整個(gè)式子上方加一個(gè)半弧妓蛮,r和s為下標(biāo)) 稱(chēng)為元組的連接(Concatenation)怠李。它是一個(gè)(n+m)列的元組,前n個(gè)分量為R中的一個(gè)n元組蛤克,后m個(gè)分量為S中的一個(gè)m元組捺癞。

4. 給定一個(gè)關(guān)系R(X,Z),X和Z為屬性組构挤。我們定義髓介,當(dāng)t[X]=x時(shí),x在R中的象集(Images Set)為:

Zx={t[Z]|t∈R, t[X]=x}

x在R中的像集為R中Z屬性對(duì)應(yīng)分量的集合筋现,而這些分量所對(duì)應(yīng)的元組中的屬性組X上的值為x版保。

例如,x_1在R中的像集Z_(x_1 )={Z_1夫否,Z_2,Z_3叫胁,Z_4}凰慈, x_2在R中的像集Z_(x_2 )={Z_2,Z_3}驼鹅,x_3在R中的像集Z_(x_3 )={Z_1微谓,Z_3}。

X1Z1

X1Z2

X1Z3

X1Z4

X2Z2

X2Z3

X3Z1

X3Z3

1. 選擇(Selection)

選擇又稱(chēng)為限制(Restriction)输钩。它是在關(guān)系R中選擇滿足給定條件的諸元組豺型,記作:

σF(R) = {t|t∈R ∧ F(t)='真'}

其中F表示選擇條件,它是一個(gè)邏輯表達(dá)式买乃,取邏輯值‘真’或‘假’姻氨。

邏輯表達(dá)式F的基本形式為:

X1 θ Y1 [ φ X2 θ Y2 ]

θ表示比較運(yùn)算符,它可以是>剪验、≥肴焊、<、≤功戚、=或≠娶眷。X1、Y1等是屬性名或常量或簡(jiǎn)單函數(shù)啸臀。屬性名也可以用它的序號(hào)來(lái)代替届宠。φ表示邏輯運(yùn)算符,它可以是フ、∧或∨豌注。[ ]表示任選項(xiàng)伤塌,即[ ]中的部分可以要也可以不要,...表示上述格式可以重復(fù)下去幌羞。

因此選擇運(yùn)算實(shí)際上是從關(guān)系R中選取使邏輯表達(dá)式F為真的元組寸谜。這是從行的角度進(jìn)行的運(yùn)算。

2. 投影(Projection)

關(guān)系R上的投影是從R中選擇出若干屬性列組成新的關(guān)系属桦。記作:

ΠA(R) = { t[A] | t∈R }

其中A為R中的屬性列熊痴。

3. 連接(Join)

連接包括:θ連接,自然連接聂宾,外連接果善,半連接。

Join 是從兩個(gè)關(guān)系的笛卡爾積中系谐,選取屬性間滿足一定條件的元組巾陕。

連接運(yùn)算從R和S的笛卡爾積R×S中選取(R關(guān)系)在A屬性組上的值與(S關(guān)系)在B屬性組上值滿足比較關(guān)系θ的元組纪他。

連接運(yùn)算中有兩種最為重要也最為常用的連接:

1.等值連接(Equal join)

2.自然連接(Natural join)

θ為“=”的連接運(yùn)算稱(chēng)為等值連接鄙煤。它是從關(guān)系R與S的笛卡爾積中選取A、B屬性值相等的那些元組茶袒。

自然連接(Natural join)是一種特殊的等值連接梯刚,它要求兩個(gè)關(guān)系中進(jìn)行比較的分量必須是相同的屬性組,并且要在結(jié)果中把重復(fù)的屬性去掉薪寓。

一般的連接操作是從行的角度進(jìn)行運(yùn)算亡资。但自然連接還需要取消了重復(fù)列,所以是同時(shí)從行和列的角度進(jìn)行運(yùn)算向叉。

4. 除(Division)

除法運(yùn)算是一個(gè)復(fù)合的二目運(yùn)算锥腻。如果把笛卡爾積看作“乘法”運(yùn)算,則除法運(yùn)算可以看作這個(gè)“乘法”的逆運(yùn)算母谎。

給定關(guān)系R(X瘦黑,Y)和S(Y,Z)奇唤,其中X供璧、Y、Z為屬性組冻记。R中的Y與S中的Y可以有不同的屬性名睡毒,但必須出自相同的域集。R與S的除運(yùn)算得到一個(gè)新的關(guān)系P(X)冗栗,P是R中滿足下列條件的元組在X屬性列上的投影:元組在X上的分量值x的像集YX包含S在Y上投影的集合演顾。記作:

R÷S={t_r [X]|t_r∈R, π_r(S)Y_x}

其中供搀,Y_x 為 x在R中的像集,x=t_r [X]钠至。顯然葛虐,除操作是同時(shí)從行和列的角度進(jìn)行運(yùn)算。

根據(jù)關(guān)系運(yùn)算的除法定義棉钧,可以得出它的運(yùn)算步驟屿脐。

(1) 將被除關(guān)系的屬性分為像集屬性和結(jié)果屬性?xún)刹糠郑慌c除關(guān)系相同的屬性屬于像集屬性宪卿;不相同的屬性屬于結(jié)果屬性的诵。

(2) 在除關(guān)系中,對(duì)像集屬性投影佑钾,得到除目標(biāo)數(shù)據(jù)集西疤。

(3) 將被除關(guān)系分組。分組原則是:結(jié)果屬性值一樣的元組分為一組休溶。

(4) 逐一考察每個(gè)組代赁,如果它的像集屬性值中包括目標(biāo)數(shù)據(jù)集,則對(duì)應(yīng)的結(jié)果屬性應(yīng)屬于該除法運(yùn)算結(jié)果集兽掰。



番外篇

歷史小傳:美國(guó)國(guó)家標(biāo)準(zhǔn)協(xié)會(huì)(American National Standard Institute, ANSI)的數(shù)據(jù)庫(kù)管理系統(tǒng)研究小組于1978年提出了標(biāo)準(zhǔn)化的建議芭碍,將數(shù)據(jù)庫(kù)結(jié)構(gòu)分為3級(jí):

1.面向用戶(hù)或應(yīng)用程序員的用戶(hù)級(jí)、

2.面向建立和維護(hù)數(shù)據(jù)庫(kù)人員的概念級(jí)孽尽、

3.面向系統(tǒng)程序員的物理級(jí)窖壕。


Database 3-Level Architecture: Three Schema Architecture of DBMS

The three schema architecture describes how the data is represented or viewed by the user in the database. This architecture is also known as?three-level architecture?and is sometimes called?ANSI/ SPARC?architecture.

The three?schema architecture?divides the database into three-level to create a separation between the?physical database and the user application. In simple words, this architecture hides the details of physical storage from the user. The database administrator (DBA) should be able to change the structure of database storage without affecting the user’s view.

This architecture contains three layers or levels of the database management system:

External level

Conceptual level

Internal level

Three Schema Architecture of DBMS

1. External or View level:?This is the highest level of database abstraction. External or view level describes the actual view of data that is relevant to the particular user. This level also provides different views of the same database for a specific user or a group of users. An external view provides a powerful and flexible security mechanism by hiding the parts of the database from a particular user.

2. Conceptual or Logical level:?The conceptual level describes the structure of the whole database. This level acts as a middle layer between the physical storage and user view. It explains what data to be stored in the database, what relationship exists among those data, and what the datatypes are. There is only one conceptual schema per database.

Database administrator and the programmers work at this level. This level does not provide any access or storage details but concentrates on the relational model of the database. The conceptual schema also includes features that specify the checks to retain integrity and consistency.

3. Internal or Physical level:?This is the lowest level of database abstraction. It describes how the data is actually stored in the database and provides methods to access data from the database. It allows viewing the physical representation of the database on the computer system. The interface between the conceptual schema and the internal schema identifies how an element in the conceptual schema is stored and how it may be accessed.

If there is any change in the internal or physical schema, it needs to be addressed to the interface between the conceptual and internal schema. But there is no need to change in the interface of a conceptual and external schema. It means that the changes in physical storage devices such as hard disks, and the files organized on storage devices, are transparent to application programs and users.

Advantages of Three-schema Architecture

Following are the advantages of three schema architecture:

1.This architecture makes the database abstract. It is used to hide the details of how data is physically stored in a computer system, which makes it easier to use for a user.

2.This architecture allows each user to access the same database with a different customized view of data.

3.This architecture enables a database admin to change the storage structure of the database without affecting the user currently on the system.


DBMS Schemas: Internal, Conceptual, External

Database systems comprise of complex data structures. Thus, to make the system efficient for retrieval of data and reduce the complexity of the users, developers use the method of Data Abstraction.

There are mainly three levels of data abstraction:

Internal Level: Actual PHYSICAL storage structure and access paths.

Conceptual or Logical Level: Structure and constraints for the entire database

External or View level: Describes various user views

Let’s study them in detail.

Internal Level/Schema

內(nèi)部模式定義了數(shù)據(jù)庫(kù)的物理存儲(chǔ)結(jié)構(gòu)。內(nèi)部模式是整個(gè)數(shù)據(jù)庫(kù)的非常低級(jí)的表示泻云。它包含多次出現(xiàn)的多種類(lèi)型的內(nèi)部記錄。在 ANSI 術(shù)語(yǔ)中狐蜕,它也被稱(chēng)為“存儲(chǔ)記錄”宠纯。

The internal schema defines the physical storage structure of the database. The internal schema is a very low-level representation of the entire database. It contains multiple occurrences of multiple types of internal record. In the ANSI term, it is also called “stored record’.

關(guān)于內(nèi)部架構(gòu)的事實(shí):

內(nèi)部架構(gòu)是數(shù)據(jù)抽象的最低級(jí)別,它幫助您保留有關(guān)整個(gè)數(shù)據(jù)庫(kù)的實(shí)際表示的信息层释。就像將數(shù)據(jù)以記錄的形式實(shí)際存儲(chǔ)在磁盤(pán)上一樣婆瓜,內(nèi)部視圖告訴我們數(shù)據(jù)庫(kù)中存儲(chǔ)了哪些數(shù)據(jù)以及如何處理它從不與物理設(shè)備打交道,內(nèi)部模式將物理設(shè)備視為物理頁(yè)面的集合贡羔。

Facts about Internal schema:

The internal schema is the lowest level of data abstraction

It helps you to keeps information about the actual representation of the entire database. Like the actual storage of the data on the disk in the form of records

The internal view tells us what data is stored in the database and how

It never deals with the physical devices. Instead, internal schema views a physical device as a collection of physical pages

Conceptual Schema/Level

概念模式是for用戶(hù)的廉白。描述了數(shù)據(jù)庫(kù)的邏輯結(jié)構(gòu)。該模式隱藏了有關(guān)物理存儲(chǔ)結(jié)構(gòu)的信息乖寒,側(cè)重于描述數(shù)據(jù)類(lèi)型猴蹂、實(shí)體、關(guān)系等楣嘁。

該邏輯級(jí)別介于用戶(hù)級(jí)別和物理存儲(chǔ)視圖之間磅轻。

The conceptual schema describes the Database structure of the whole database for the community of users. This schema hides information about the physical storage structures and focuses on describing data types, entities, relationships, etc.

This logical level comes between the user level and physical storage view.?

關(guān)于概念模式的事實(shí):

定義所有數(shù)據(jù)庫(kù)實(shí)體珍逸、它們的屬性和它們的關(guān)系

安全和完整性信息

在概念層面,用戶(hù)可用的數(shù)據(jù)必須包含在物理層面或從物理層面推導(dǎo)出來(lái)聋溜。

Facts about Conceptual schema:

Defines all database entities, their attributes, and their relationships

Security and integrity (完整性)information

In the conceptual level, the data available to a user must be contained in or derivable (推導(dǎo))from the physical level谆膳。

External Schema/Level

外部架構(gòu)/級(jí)別

外部模式描述了特定用戶(hù)感興趣的數(shù)據(jù)庫(kù)部分。它向用戶(hù)隱藏了數(shù)據(jù)庫(kù)的無(wú)關(guān)細(xì)節(jié)撮躁。每個(gè)數(shù)據(jù)庫(kù)可能有“n”個(gè)外部視圖漱病。

每個(gè)外部視圖都使用外部模式定義,該模式由該特定視圖的各種類(lèi)型的外部記錄的定義組成把曼。

外部視圖只是某些特定用戶(hù)看到的數(shù)據(jù)庫(kù)內(nèi)容杨帽。例如,銷(xiāo)售部門(mén)的用戶(hù)將只能看到與銷(xiāo)售相關(guān)的數(shù)據(jù)祝迂。

An external schema describes the part of the database which specific user is interested in. It hides the unrelated details of the database from the user. There may be “n” number of external views for each database.

Each external view is defined using an external schema, which consists of definitions of various types of external record of that specific view.

An external view is just the content of the database as it is seen by some specific particular user. For example, a user from the sales department will see only sales related data.

關(guān)于外部架構(gòu)的事實(shí):

外部級(jí)別僅與特定最終用戶(hù)查看的數(shù)據(jù)相關(guān)睦尽。

此級(jí)別包括一些外部模式。

外部架構(gòu)級(jí)別離用戶(hù)最近

外部模式描述了特定用戶(hù)組所需的數(shù)據(jù)庫(kù)段型雳,并對(duì)特定用戶(hù)組隱藏了數(shù)據(jù)庫(kù)中的其余詳細(xì)信息

Facts about external schema:

An external level is only related to the data which is viewed by specific end users.

This level includes some external schemas.

External schema level is nearest to the user

The external schema describes the segment of the database which is needed for a certain user group and hides the remaining details from the database from the specific user group

Goal of 3 level/schema of Database

數(shù)據(jù)庫(kù)的 3 級(jí)/模式的目標(biāo)

以下是使用三模式架構(gòu)的一些目標(biāo):

每個(gè)用戶(hù)都應(yīng)該能夠訪問(wèn)相同的數(shù)據(jù)当凡,也能自定義視圖。

用戶(hù)無(wú)需直接處理物理數(shù)據(jù)庫(kù)存儲(chǔ)細(xì)節(jié)纠俭。

DBA 應(yīng)該能夠在不干擾用戶(hù)視圖的情況下沿量,更改數(shù)據(jù)庫(kù)存儲(chǔ)結(jié)構(gòu)。

當(dāng)對(duì)存儲(chǔ)的物理方面進(jìn)行更改時(shí)冤荆,數(shù)據(jù)庫(kù)的內(nèi)部結(jié)構(gòu)應(yīng)保持不受影響朴则。

Here, are some Objectives of using Three schema Architecture:

Every user should be able to access the same data but able to see a customized view of the data.

The user need not to deal directly with physical database storage detail.

The DBA should be able to change the database storage structure without disturbing the user’s views

The internal structure of the database should remain unaffected when changes made to the physical aspects of storage.

Advantages Database Schema

您可以獨(dú)立于物理存儲(chǔ)管理數(shù)據(jù)

更快地遷移到新的圖形環(huán)境

DBMS 體系結(jié)構(gòu)允許您在表示級(jí)別進(jìn)行更改而不影響其他兩層

由于每一層都是獨(dú)立的,因此可以使用不同的開(kāi)發(fā)人員集

由于客戶(hù)端無(wú)法直接訪問(wèn)數(shù)據(jù)庫(kù)業(yè)務(wù)邏輯钓简,因此更安全

如果一層發(fā)生故障乌妒,則不會(huì)丟失數(shù)據(jù),因?yàn)槟冀K可以通過(guò)訪問(wèn)另一層來(lái)確保安全

You can manage data independent of the physical storage

Faster Migration to new graphical environments

DBMS Architecture allows you to make changes on the presentation level without affecting the other two layers

As each tier is separate, it is possible to use different sets of developers

It is more secure as the client doesn’t have direct access to the database business logic

In case of the failure of the one-tier no data loss as you are always secure by accessing the other tier

Disadvantages Database Schema

1.復(fù)雜性:完整的 DB Schema 是一個(gè)復(fù)雜的結(jié)構(gòu)外邓,每個(gè)人都難以理解

2.運(yùn)維:成本高撤蚊,難。

3.性能:層的物理分離會(huì)影響數(shù)據(jù)庫(kù)的性能损话。

Complete DB Schema is a complex structure which is difficult to understand for every one

Difficult to set up and maintain

The physical separation of the tiers can affect the performance of the Database

Summary

1.數(shù)據(jù)抽象主要有三個(gè)層次:物理層(內(nèi)部模式)侦啸、邏輯層(概念模式)、用戶(hù)層(外部模式)丧枪。

2.內(nèi)部模式定義了數(shù)據(jù)庫(kù)的物理存儲(chǔ)結(jié)構(gòu)

3.概念模式為用戶(hù)社區(qū)描述了整個(gè)數(shù)據(jù)庫(kù)的數(shù)據(jù)庫(kù)結(jié)構(gòu)

4.外部模式描述了特定用戶(hù)感興趣的數(shù)據(jù)庫(kù)部分

5.DBMS 體系結(jié)構(gòu)允許您在表示級(jí)別進(jìn)行更改而不影響其他兩層光涂。


There are mainly three levels of data abstraction: Internal Level, Conceptual or Logical Level or External or View level

The internal schema defines the physical storage structure of the database

The conceptual schema describes the Database structure of the whole database for the community of users

An external schema describe the part of the database which specific user is interested in

DBMS Architecture allows you to make changes on the presentation level without affecting the other two layers




Following are the three levels of database architecture,

1. Physical Level

2. Conceptual Level

3. External Level

In the above diagram,?It shows the architecture of DBMS.

Mapping is the process of transforming request response between various database levels of architecture. Mapping is not good for small database, because it takes more time.

In External - Conceptual (User - Logical)mapping, DBMS transforms a request on an external schema against the conceptual schema.

In Conceptual - Internal mapping(Logical - Physical), it is necessary to transform the request from the conceptual to internal levels.

1. External Level

External level is related to the data which is viewed by individual end users.

This level includes a no. of user views or external schemas.

This level is closest to the user.

External view describes the segment of the database that is required for a particular user group and hides the rest of the database from that user group.

2. Conceptual Level

Conceptual level describes the structure of the whole database for a group of users.

It is also called as the data model.

Conceptual schema is a representation of the entire content of the database.

These schema contains all the information to build relevant external records.

It hides the internal details of physical storage.

3. Physical Level

Physical level describes the physical storage structure of data in database.

It is also known as Internal Level.This level is very close to physical storage of data.

At lowest level, it is stored in the form of bits with the physical addresses on the secondary storage device.

At highest level, it can be viewed in the form of files.

The internal schema defines the various stored data types. It uses a physical data model.

1.外模式(用戶(hù)層)

外模式又稱(chēng)子模式或用戶(hù)模式,對(duì)應(yīng)于用戶(hù)級(jí)拧烦。它是某個(gè)或某幾個(gè)用戶(hù)所看到的數(shù)據(jù)庫(kù)的數(shù)據(jù)視圖忘闻,是與某一應(yīng)用有關(guān)的數(shù)據(jù)的邏輯表示。外模式是從模式導(dǎo)出的一個(gè)子集恋博,包含模式中允許特定用戶(hù)使用的那部分?jǐn)?shù)據(jù)服赎。用戶(hù)可以通過(guò)外模式描述語(yǔ)言來(lái)描述葵蒂、定義對(duì)應(yīng)于用戶(hù)的數(shù)據(jù)記錄(外模式),也可以利用數(shù)據(jù)操縱語(yǔ)言(Data Manipulation Language重虑,DML)對(duì)這些數(shù)據(jù)記錄進(jìn)行操作践付。外模式反映了數(shù)據(jù)庫(kù)系統(tǒng)的用戶(hù)觀。

2.概念模式(邏輯層)

概念模式又稱(chēng)模式或邏輯模式缺厉,對(duì)應(yīng)于概念級(jí)永高。它是由數(shù)據(jù)庫(kù)設(shè)計(jì)者綜合所有用戶(hù)的數(shù)據(jù),按照統(tǒng)一的觀點(diǎn)構(gòu)造的全局邏輯結(jié)構(gòu)提针,是對(duì)數(shù)據(jù)庫(kù)中全部數(shù)據(jù)的邏輯結(jié)構(gòu)和特征的總體描述命爬,是所有用戶(hù)的公共數(shù)據(jù)視圖(全局視圖)。它是由數(shù)據(jù)庫(kù)管理系統(tǒng)提供的數(shù)據(jù)模式描述語(yǔ)言(Data Description Language辐脖,DDL)來(lái)描述饲宛、定義的。概念模式反映了數(shù)據(jù)庫(kù)系統(tǒng)的整體觀嗜价。

3.內(nèi)模式(物理存儲(chǔ)層)

內(nèi)模式又稱(chēng)存儲(chǔ)模式艇抠,對(duì)應(yīng)于物理級(jí)。它是數(shù)據(jù)庫(kù)中全體數(shù)據(jù)的內(nèi)部表示或底層描述久锥,是數(shù)據(jù)庫(kù)最低一級(jí)的邏輯描述家淤,它描述了數(shù)據(jù)在存儲(chǔ)介質(zhì)上的存儲(chǔ)方式和物理結(jié)構(gòu),對(duì)應(yīng)著實(shí)際存儲(chǔ)在外存儲(chǔ)介質(zhì)上的數(shù)據(jù)庫(kù)瑟由。內(nèi)模式由內(nèi)模式描述語(yǔ)言來(lái)描述絮重、定義的。內(nèi)模式反映了數(shù)據(jù)庫(kù)系統(tǒng)的存儲(chǔ)觀歹苦。

A conceptual view of the three level architecture ?


數(shù)據(jù)庫(kù)的三級(jí)模式青伤,是數(shù)據(jù)庫(kù)在三個(gè)級(jí)別 (層次)上的抽象,使用戶(hù)能夠邏輯地殴瘦、抽象地處理數(shù)據(jù)狠角,而不必關(guān)心數(shù)據(jù)在計(jì)算機(jī)中的物理表示和存儲(chǔ)


Three levels of models.

實(shí)際上 痴施,對(duì)于一個(gè)數(shù)據(jù)庫(kù)系統(tǒng)而言:

1.物理級(jí)數(shù)據(jù)庫(kù)是進(jìn)行數(shù)據(jù)庫(kù)操作的基礎(chǔ)擎厢。

2.概念級(jí)數(shù)據(jù)庫(kù)中不過(guò)是物理數(shù)據(jù)庫(kù)的一種邏輯的究流、抽象的描述(即模式)辣吃。

3.用戶(hù)級(jí)數(shù)據(jù)庫(kù)則是用戶(hù)與數(shù)據(jù)庫(kù)的接口,它是概念級(jí)數(shù)據(jù)庫(kù)的一個(gè)子集(外模式)芬探。

用戶(hù)應(yīng)用程序根據(jù)外模式進(jìn)行數(shù)據(jù)操作神得,通過(guò)外模式一模式映射,定義和建立某個(gè)外模式與模式間的對(duì)應(yīng)關(guān)系偷仿,將外模式與模式聯(lián)系起來(lái)哩簿,當(dāng)模式發(fā)生改變時(shí)宵蕉,只要改變其映射,就可以使外模式保持不變节榜,對(duì)應(yīng)的應(yīng)用程序也可保持不變羡玛;

另一方面,通過(guò)模式一內(nèi)模式映射宗苍,定義建立數(shù)據(jù)的邏輯結(jié)構(gòu)(模式)與存儲(chǔ)結(jié)構(gòu)(內(nèi)模式)間的對(duì)應(yīng)關(guān)系稼稿,當(dāng)數(shù)據(jù)的存儲(chǔ)結(jié)構(gòu)發(fā)生變化時(shí),只需改變模式一內(nèi)模式映射讳窟,就能保持模式不變让歼,因此應(yīng)用程序也可以保持不變。

數(shù)據(jù)庫(kù)的兩級(jí)映射


數(shù)據(jù)庫(kù)系統(tǒng)在三級(jí)模式之間提供了兩級(jí)映像:

邏輯層(模式)-物理層(內(nèi)模式)的映像:實(shí)現(xiàn)概念模式到內(nèi)模式之間的相互轉(zhuǎn)換丽啡。

用戶(hù)層(外模式)-邏輯層(模式)的映像:實(shí)現(xiàn)外模式到概念模式之間的相互轉(zhuǎn)換谋右。

數(shù)據(jù)的獨(dú)立性是指數(shù)據(jù)與程序獨(dú)立,將數(shù)據(jù)的定義從程序中分離出來(lái)补箍,由DBMS(數(shù)據(jù)庫(kù)管理系統(tǒng))負(fù)責(zé)數(shù)據(jù)的存儲(chǔ)改执,從而簡(jiǎn)化應(yīng)用程序,大大減少應(yīng)用程序編制的工作量馏予。

數(shù)據(jù)的獨(dú)立性是由DBMS的二級(jí)映像功能來(lái)保證的天梧。數(shù)據(jù)的獨(dú)立性包括數(shù)據(jù)的物理獨(dú)立性和數(shù)據(jù)的邏輯獨(dú)立性。

什么是數(shù)據(jù)的物理獨(dú)立性霞丧?

答:數(shù)據(jù)的物理獨(dú)立性是指當(dāng)數(shù)據(jù)庫(kù)的內(nèi)模式發(fā)生改變時(shí)呢岗,數(shù)據(jù)的的邏輯結(jié)構(gòu)不變。由于應(yīng)用程序處理的只是數(shù)據(jù)的邏輯結(jié)構(gòu)蛹尝,這樣物理獨(dú)立性可以保證后豫,當(dāng)數(shù)據(jù)的物理結(jié)構(gòu)改變了,應(yīng)用程序不用改變突那。但是挫酿,為了保證應(yīng)用程序能夠正確執(zhí)行,需要修改概念模式/內(nèi)模式之間的映像愕难。

什么是數(shù)據(jù)的邏輯獨(dú)立性早龟?

答:數(shù)據(jù)的邏輯獨(dú)立性是指用戶(hù)的應(yīng)用程序與數(shù)據(jù)庫(kù)結(jié)構(gòu)是相互獨(dú)立的。數(shù)據(jù)的邏輯結(jié)構(gòu)發(fā)生變化后猫缭,用戶(hù)程序也可以不修改葱弟。但是,為了保證應(yīng)用程序能夠正確執(zhí)行猜丹,需要修改外模式/概念模式之間的映像芝加。

一句話總結(jié)一下:

通俗來(lái)講就是如果改變了某個(gè)模式,只需要修改上一層的映像射窒。

即改變內(nèi)模式藏杖,只需要修改模式/內(nèi)模式映像(物理獨(dú)立性)将塑;

改變概念模式(邏輯結(jié)構(gòu)),只需要修改外模式/模式映像(邏輯獨(dú)立性)

DBMS Three Level Architecture Diagram

This architecture has three levels:

1. External level

2. Conceptual level

3. Internal level

1. External level

It is also called?view level. The reason this level is called “view” is because several users can view their desired data from this level which is internally fetched from database with the help of conceptual and internal level mapping.

The user doesn’t need to know the database schema details such as data structure, table definition etc. user is only concerned about data which is what returned back to the view level after it has been fetched from database (present at the internal level).

External level is the “top level” of the Three Level DBMS Architecture.

2. Conceptual level

It is also called?logical level. The whole design of the database such as relationship among data, schema of data etc. are described in this level.

Database constraints and security are also implemented in this level of architecture. This level is maintained by DBA (database administrator).

3. Internal level

This level is also known as physical level. This level describes how the data is actually stored in the storage devices. This level is also responsible for allocating space to the data. This is the lowest level of the architecture.

數(shù)據(jù)倉(cāng)庫(kù):Data Warehousing

關(guān)鍵詞:數(shù)據(jù)倉(cāng)庫(kù)蝌麸,物理設(shè)計(jì)点寥,非關(guān)系型數(shù)據(jù)庫(kù),OLAP查詢(xún)處理来吩,HBase开财,星型模式基準(zhǔn)。

Data Warehousing, Physical Design, NoSQL, OLAP Query Processing, HBase, Star Schema Benchmark.

數(shù)據(jù)倉(cāng)庫(kù)和在線分析處理(OLAP)是當(dāng)今商業(yè)智能研究的核心技術(shù)误褪,近十年來(lái)受到了研究者的廣泛關(guān)注责鳍。OLAP查詢(xún)的流轉(zhuǎn)時(shí)長(zhǎng),受到物理數(shù)據(jù)倉(cāng)庫(kù)設(shè)計(jì)和訪問(wèn)的維度和數(shù)據(jù)量的影響兽间。使用不同的屬性分布列族可以提高HBase中的OLAP查詢(xún)性能历葛,從而形成基準(zhǔn)更適合非關(guān)系型數(shù)據(jù)庫(kù)的OLAP。

Three-level DW architecture for NoSQL column-oriented(列式存儲(chǔ)) databases:

小結(jié)

1.三級(jí)模式結(jié)構(gòu):外模式(用戶(hù)級(jí))嘀略、概念模式(概念級(jí))恤溶、內(nèi)模式(物理級(jí))。

2.目的:更加有效地組織帜羊、管理數(shù)據(jù)咒程,提高數(shù)據(jù)庫(kù)的邏輯獨(dú)立性和物理獨(dú)立性。不同級(jí)別的用戶(hù)讼育,對(duì)數(shù)據(jù)庫(kù)形成不同的視圖帐姻。所謂視圖,就是指觀察奶段、認(rèn)識(shí)和理解數(shù)據(jù)的范圍饥瓷、角度和方法,是數(shù)據(jù)庫(kù)在用戶(hù)“眼中"的反映痹籍,很顯然呢铆,不同層次(級(jí)別)用戶(hù)所“看到”的數(shù)據(jù)庫(kù)是不相同的。

3.好處:解耦蹲缠,隔離棺克。數(shù)據(jù)按外模式的描述提供給用戶(hù);按內(nèi)模式的描述存儲(chǔ)在磁盤(pán)上线定;而概念模式提供了連接這兩級(jí)模式的相對(duì)穩(wěn)定的中間層娜谊,并使得兩級(jí)中任意一級(jí)的改變都不受另一級(jí)的牽制。

參考資料

https://svitla.com/blog/database-management-software

http://jcsites.juniata.edu/faculty/rhodes/dbms/dbarch.htm

https://www.geeksforgeeks.org/introduction-of-3-tier-architecture-in-dbms-set-2/

https://www.guru99.com/dbms-schemas.html



《ClickHouse 實(shí)戰(zhàn):企業(yè)級(jí)大數(shù)據(jù)分析引擎教程》

內(nèi)容簡(jiǎn)介

Create scalable, fault-tolerant, and reliable online analytical applications with a feature-rich DBMS designed for speed.

Key Features

● Hands-on approach towards learning ClickHouse from basic to advanced level.

● Numerous examples demonstrating how to use ClickHouse for analytical tasks.

● Straightforward explanations for complex concepts on ClickHouse and its vast features.

● Integration with a variety of technologies such as MySQL, PostgreSQL, Kafka, and Amazon S3.

Description

This book provides a hands-on approach for data professionals to onboard ClickHouse and empowers the readers to perform real-time analytics using ClickHouse SQL.

The readers will understand the fundamentals of database technologies and frequently used relational database concepts such as keys, database normalisation etc. The readers will learn to query the data using SQL (ClickHouse dialect), configure databases and tables in ClickHouse and use the various types of core table engines available in ClickHouse, including the MergeTree and Log family engines. The readers will be able to investigate and practically integrate ClickHouse with various external data sources and work with unique table engines shipped with ClickHouse. With help of the examples provided, readers will be able to gain experience in configuring the ClickHouse setup and perform administrative tasks in the ClickHouse Server.

Throughout this journey, readers will reinforce their learning by using numerous working examples and the question and answer section at the end of each chapter. By the end of this book, readers will be able to apply their knowledge and utilize ClickHouse in real-world applications.

What you will learn

● Querying the tables in ClickHouse and performing analytical tasks using ClickHouse SQL.

● Integrating and running queries with popular RDBMS, including MySQL and PostgreSQL.

● Integrating with cloud storage and streaming platforms such as S3 and Kafka.

● Working with Core engines and special engines.

● Configure the ClickHouse setup and carry out administrative tasks.

Who this book is for

This book is intended for data engineers, application developers, database administrators and software architects who want to learn ClickHouse.

Table of Contents

1. Introduction

2. The Relational Database Model and Database Design

3. Setting up the Environment

4. ClickHouse SQL

5. SQL Functions in ClickHouse

6. SQL Functions for Data Aggregation

7. Table Engines (表引擎)- MergeTree Family

8. Table Engines - Log Family

9. External Data Sources(ClickHouse與外部應(yīng)用程序集成)

10. Special Engines

11. Configuring the ClickHouse Setup – Part 1

12. Configuring the ClickHouse Setup – Part 2

名詞說(shuō)明

Big Data:大數(shù)據(jù)

data engineering:數(shù)據(jù)工程

data science:數(shù)據(jù)科學(xué)

database design:數(shù)據(jù)庫(kù)設(shè)計(jì)

machine learning:機(jī)器學(xué)習(xí)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末渔肩,一起剝皮案震驚了整個(gè)濱河市因俐,隨后出現(xiàn)的幾起案子拇惋,更是在濱河造成了極大的恐慌周偎,老刑警劉巖抹剩,帶你破解...
    沈念sama閱讀 219,490評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異蓉坎,居然都是意外死亡澳眷,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,581評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門(mén)蛉艾,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)钳踊,“玉大人,你說(shuō)我怎么就攤上這事勿侯⊥氐桑” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 165,830評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵助琐,是天一觀的道長(zhǎng)祭埂。 經(jīng)常有香客問(wèn)我,道長(zhǎng)兵钮,這世上最難降的妖魔是什么蛆橡? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 58,957評(píng)論 1 295
  • 正文 為了忘掉前任,我火速辦了婚禮掘譬,結(jié)果婚禮上泰演,老公的妹妹穿的比我還像新娘。我一直安慰自己葱轩,他們只是感情好睦焕,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,974評(píng)論 6 393
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著靴拱,像睡著了一般复亏。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上缭嫡,一...
    開(kāi)封第一講書(shū)人閱讀 51,754評(píng)論 1 307
  • 那天缔御,我揣著相機(jī)與錄音,去河邊找鬼妇蛀。 笑死耕突,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的评架。 我是一名探鬼主播眷茁,決...
    沈念sama閱讀 40,464評(píng)論 3 420
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼纵诞!你這毒婦竟也來(lái)了祥山?” 一聲冷哼從身側(cè)響起茉稠,我...
    開(kāi)封第一講書(shū)人閱讀 39,357評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤务热,失蹤者是張志新(化名)和其女友劉穎耀怜,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,847評(píng)論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,995評(píng)論 3 338
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了皇耗。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,137評(píng)論 1 351
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡揍很,死狀恐怖郎楼,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情窒悔,我是刑警寧澤呜袁,帶...
    沈念sama閱讀 35,819評(píng)論 5 346
  • 正文 年R本政府宣布,位于F島的核電站简珠,受9級(jí)特大地震影響傅寡,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜北救,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,482評(píng)論 3 331
  • 文/蒙蒙 一荐操、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧珍策,春花似錦托启、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 32,023評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至蹭劈,卻和暖如春疗绣,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背铺韧。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 33,149評(píng)論 1 272
  • 我被黑心中介騙來(lái)泰國(guó)打工多矮, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人哈打。 一個(gè)月前我還...
    沈念sama閱讀 48,409評(píng)論 3 373
  • 正文 我出身青樓塔逃,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親料仗。 傳聞我的和親對(duì)象是個(gè)殘疾皇子湾盗,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,086評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容