Tuple relational calculus

Tuple calculus is a calculus that was created and introduced by Edgar F. Codd as part of the relational model, in order to provide a declarative database-query language for data manipulation in this data model. It formed the inspiration for the database-query languages QUEL and SQL, of which the latter, although far less faithful to the original relational model and calculus, is now the de facto standard database-query language; a dialect of SQL is used by nearly every relational-database-management system. Michel Lacroix and Alain Pirotte proposed domain calculus, which is closer to first-order logic and together with Codd showed that both of these calculi (as well as relational algebra) are equivalent in expressive power. Subsequently, query languages for the relational model were called relationally complete if they could express at least all of these queries.

Definition

Relational database

Since the calculus is a query language for relational databases we first have to define a relational database. The basic relational building block is the domain (somewhat similar, but not equal to, a data type). A tuple is a finite sequence of attributes, which are ordered pairs of domains and values. A relation is a set of (compatible) tuples. Although these relational concepts are mathematically defined, those definitions map loosely to traditional database concepts. A table is an accepted visual representation of a relation; a tuple is similar to the concept of a row.

We first assume the existence of a set C of column names, examples of which are "name", "author", "address", etcetera. We define headers as finite subsets of C. A relational database schema is defined as a tuple S = (D, R, h) where D is the domain of atomic values (see relational model for more on the notions of domain and atomic value), R is a finite set of relation names, and

h : R → 2C

a function that associates a header with each relation name in R. (Note that this is a simplification from the full relational model where there is more than one domain and a header is not just a set of column names but also maps these column names to a domain.) Given a domain D we define a tuple over D as a partial function that maps some column names to an atomic value in D. An example would be (name : "Harry", age : 25).

t : CD

The set of all tuples over D is denoted as TD. The subset of C for which a tuple t is defined is called the domain of t (not to be confused with the domain in the schema) and denoted as dom(t).

Finally we define a relational database given a schema S = (D, R, h) as a function

db : R → 2TD

that maps the relation names in R to finite subsets of TD, such that for every relation name r in R and tuple t in db(r) it holds that

dom(t) = h(r).

The latter requirement simply says that all the tuples in a relation should contain the same column names, namely those defined for it in the schema.

Atoms

For the construction of the formulas we will assume an infinite set V of tuple variables. The formulas are defined given a database schema S = (D, R, h) and a partial function type : V ⇸ 2C, called at type assignment, that assigns headers to some tuple variables. We then define the set of atomic formulas A[S,type] with the following rules:

  1. if v and w in V, a in type(v) and b in type(w) then the formula v.a = w.b is in A[S,type],
  2. if v in V, a in type(v) and k denotes a value in D then the formula v.a = k is in A[S,type], and
  3. if v in V, r in R and type(v) = h(r) then the formula r(v) is in A[S,type].

Examples of atoms are:

  • (t.age = s.age) — t has an age attribute and s has an age attribute with the same value
  • (t.name = "Codd") — tuple t has a name attribute and its value is "Codd"
  • Book(t) — tuple t is present in relation Book.

The formal semantics of such atoms is defined given a database db over S and a tuple variable binding val : VTD that maps tuple variables to tuples over the domain in S:

  1. v.a = w.b is true if and only if val(v)(a) = val(w)(b)
  2. v.a = k is true if and only if val(v)(a) = k
  3. r(v) is true if and only if val(v) is in db(r)

Formulas

The atoms can be combined into formulas, as is usual in first-order logic, with the logical operators ∧ (and), ∨ (or) and ¬ (not), and we can use the existential quantifier (∃) and the universal quantifier (∀) to bind the variables. We define the set of formulas F[S,type] inductively with the following rules:

  1. every atom in A[S,type] is also in F[S,type]
  2. if f1 and f2 are in F[S,type] then the formula f1f2 is also in F[S,type]
  3. if f1 and f2 are in F[S,type] then the formula f1f2 is also in F[S,type]
  4. if f is in F[S,type] then the formula ¬ f is also in F[S,type]
  5. if v in V, H a header and f a formula in F[S,type[v->H]] then the formula ∃ v : H ( f ) is also in F[S,type], where type[v->H] denotes the function that is equal to type except that it maps v to H,
  6. if v in V, H a header and f a formula in F[S,type[v->H]] then the formula ∀ v : H ( f ) is also in F[S,type]

Examples of formulas:

  • t.name = "C. J. Date" ∨ t.name = "H. Darwen"
  • Book(t) ∨ Magazine(t)
  • t : {author, title, subject} ( ¬ ( Book(t) ∧ t.author = "C. J. Date" ∧ ¬ ( t.subject = "relational model")))

Note that the last formula states that all books that are written by C. J. Date have as their subject the relational model. As usual we omit brackets if this causes no ambiguity about the semantics of the formula.

We will assume that the quantifiers quantify over the universe of all tuples over the domain in the schema. This leads to the following formal semantics for formulas given a database db over S and a tuple variable binding val : V -> TD:

  1. f1f2 is true if and only if f1 is true and f2 is true,
  2. f1f2 is true if and only if f1 is true or f2 is true or both are true,
  3. ¬ f is true if and only if f is not true,
  4. v : H ( f ) is true if and only if there is a tuple t over D such that dom(t) = H and the formula f is true for val[v->t], and
  5. v : H ( f ) is true if and only if for all tuples t over D such that dom(t) = H the formula f is true for val[v->t].

Queries

Finally we define what a query expression looks like given a schema S = (D, R, h):

{ v : H | f(v) }

where v is a tuple variable, H a header and f(v) a formula in F[S,type] where type = { (v, H) } and with v as its only free variable. The result of such a query for a given database db over S is the set of all tuples t over D with dom(t) = H such that f is true for db and val = { (v, t) }.

Examples of query expressions are:

  • { t : {name} | ∃ s : {name, wage} ( Employee(s) ∧ s.wage = 50.000 ∧ t.name = s.name ) }
  • { t : {supplier, article} | ∃ s : {s#, sname} ( Supplier(s) ∧ s.sname = t.supplier ∧ ∃ p : {p#, pname} ( Product(p) ∧ p.pname = t.article ∧ ∃ a : {s#, p#} ( Supplies(a) ∧ s.s# = a.s# ∧ a.p# = p.p# ))) }

Semantic and syntactic restriction

Domain-independent queries

Because the semantics of the quantifiers is such that they quantify over all the tuples over the domain in the schema it can be that a query may return a different result for a certain database if another schema is presumed. For example, consider the two schemas S1 = ( D1, R, h ) and S2 = ( D2, R, h ) with domains D1 = { 1 }, D2 = { 1, 2 }, relation names R = { "r1" } and headers h = { ("r1", {"a"}) }. Both schemas have a common instance:

db = { ( "r1", { ("a", 1) } ) }

If we consider the following query expression

{ t : {a} | t.a = t.a }

then its result on db is either { (a : 1) } under S1 or { (a : 1), (a : 2) } under S2. It will also be clear that if we take the domain to be an infinite set, then the result of the query will also be infinite. To solve these problems we will restrict our attention to those queries that are domain independent, i.e., the queries that return the same result for a database under all of its schemas.

An interesting property of these queries is that if we assume that the tuple variables range over tuples over the so-called active domain of the database, which is the subset of the domain that occurs in at least one tuple in the database or in the query expression, then the semantics of the query expressions does not change. In fact, in many definitions of the tuple calculus this is how the semantics of the quantifiers is defined, which makes all queries by definition domain independent.

Safe queries

In order to limit the query expressions such that they express only domain-independent queries a syntactical notion of safe query is usually introduced. To determine whether a query expression is safe we will derive two types of information from a query. The first is whether a variable-column pair t.a is bound to the column of a relation or a constant, and the second is whether two variable-column pairs are directly or indirectly equated (denoted t.v == s.w).

For deriving boundedness we introduce the following reasoning rules:

  1. in " v.a = w.b " no variable-column pair is bound,
  2. in " v.a = k " the variable-column pair v.a is bound,
  3. in " r(v) " all pairs v.a are bound for a in type(v),
  4. in " f1f2 " all pairs are bound that are bound either in f1 or in f2,
  5. in " f1f2 " all pairs are bound that are bound both in f1 and in f2,
  6. in " ¬ f " no pairs are bound,
  7. in " ∃ v : H ( f ) " a pair w.a is bound if it is bound in f and w <> v, and
  8. in " ∀ v : H ( f ) " a pair w.a is bound if it is bound in f and w <> v.

For deriving equatedness we introduce the following reasoning rules (next to the usual reasoning rules for equivalence relations: reflexivity, symmetry and transitivity):

  1. in " v.a = w.b " it holds that v.a == w.b,
  2. in " v.a = k " no pairs are equated,
  3. in " r(v) " no pairs are equated,
  4. in " f1f2 " it holds that v.a == w.b if it holds either in f1 or in f2,
  5. in " f1f2 " it holds that v.a == w.b if it holds both in f1 and in f2,
  6. in " ¬ f " no pairs are equated,
  7. in " ∃ v : H ( f ) " it holds that w.a == x.b if it holds in f and w<>v and x<>v, and
  8. in " ∀ v : H ( f ) " it holds that w.a == x.b if it holds in f and w<>v and x<>v.

We then say that a query expression { v : H | f(v) } is safe if

  • for every column name a in H we can derive that v.a is equated with a bound pair in f,
  • for every subexpression of f of the form " ∀ w : G ( g ) " we can derive that for every column name a in G we can derive that w.a is equated with a bound pair in g, and
  • for every subexpression of f of the form " ∃ w : G ( g ) " we can derive that for every column name a in G we can derive that w.a is equated with a bound pair in g.

The restriction to safe query expressions does not limit the expressiveness since all domain-independent queries that could be expressed can also be expressed by a safe query expression. This can be proven by showing that for a schema S = (D, R, h), a given set K of constants in the query expression, a tuple variable v and a header H we can construct a safe formula for every pair v.a with a in H that states that its value is in the active domain. For example, assume that K={1,2}, R={"r"} and h = { ("r", {"a, "b"}) } then the corresponding safe formula for v.b is:

v.b = 1 ∨ v.b = 2 ∨ ∃ w ( r(w) ∧ ( v.b = w.a ∨ v.b = w.b ) )

This formula, then, can be used to rewrite any unsafe query expression to an equivalent safe query expression by adding such a formula for every variable v and column name a in its type where it is used in the expression. Effectively this means that we let all variables range over the active domain, which, as was already explained, does not change the semantics if the expressed query is domain independent.

Systems

See also

References

Read other articles:

Country in South America This article is about the country. For its larger predecessor, see Gran Colombia. For other uses, see Colombia (disambiguation) and Columbia. Not to be confused with Colombo. Republic of ColombiaRepública de Colombia (Spanish) Flag Coat of arms Motto: Libertad y Orden (Spanish)Freedom and OrderAnthem: Himno Nacional de la República de Colombia (Spanish)National Anthem of the Republic of ColombiaLocation of Colombia (dark green)Capi...

 

artikel ini perlu dirapikan agar memenuhi standar Wikipedia. Tidak ada alasan yang diberikan. Silakan kembangkan artikel ini semampu Anda. Merapikan artikel dapat dilakukan dengan wikifikasi atau membagi artikel ke paragraf-paragraf. Jika sudah dirapikan, silakan hapus templat ini. (Pelajari cara dan kapan saatnya untuk menghapus pesan templat ini) Artikel ini perlu dikembangkan agar dapat memenuhi kriteria sebagai entri Wikipedia.Bantulah untuk mengembangkan artikel ini. Jika tidak dikembang...

 

Guntur Sasono Informasi pribadiLahir2 Juli 1946MadiunKewarganegaraanIndonesiaSuami/istriDra. Hj. Retno Djumhariati, MM.Tempat tinggalIndonesiaAlma mater• Akademi Militer (1971)• Universitas 17 Agustus 1945 SurabayaPekerjaanPolitisiKarier militerPihak IndonesiaDinas/cabang TNI Angkatan DaratMasa dinas1971 —Pangkat KolonelSatuanPerhubungan – Chb.Sunting kotak info • L • B Kol. Chb. (Purn). Drs. H. Guntur Sasono, M.Si (lahir 2 Juli 1946) adalah anggota DPR RI peri...

County in Missouri, United States County in MissouriReynolds CountyCountyThe antebellum county courthouse in CentervilleLocation within the U.S. state of MissouriMissouri's location within the U.S.Coordinates: 37°22′N 90°58′W / 37.36°N 90.97°W / 37.36; -90.97Country United StatesState MissouriFoundedFebruary 25, 1845Named forThomas ReynoldsSeatCentervilleLargest cityEllingtonArea • Total814 sq mi (2,110 km2) • La...

 

Perjanjian Perdagangan Bebas Uni Eropa-Korea SelatanKorea Selatan (jingga) dan Uni Eropa (hijau)JenisPerjanjian dagangDitandatangani6 Oktober 2010LokasiBrusselsEfektif13 Desember 2015SyaratRatifikasi oleh seluruh penandatanganPenerapan sementara02024-07-011 Juli 2011Penanda tangan  Korea Selatan  Uni Eropa  Seluruh 28 negara anggota UE Ratifikasi30 (Korea Selatan, UE dan 28 negara anggotanya)BahasaKorea Seluruh 21 bahasa UE resmi BulgariaKroasiaCekoDenmarkBelandaInggrisEstoniaF...

 

2005 American filmThe Prize Winner of Defiance, OhioTheatrical release posterDirected byJane AndersonWritten byJane AndersonBased onThe Prize Winner of Defiance, Ohio: How My Mother Raised 10 Kids on 25 Words or Lessby Terry RyanProduced byJack RapkeSteve StarkeyRobert ZemeckisStarringJulianne MooreWoody HarrelsonLaura DernCinematographyJonathan FreemanEdited byRobert DalvaMusic byJohn FrizzellProductioncompaniesRevolution StudiosImageMoversDistributed byGo Fish Pictures[1] (through D...

У этого термина существуют и другие значения, см. Чайки (значения). Чайки Доминиканская чайкаЗападная чайкаКалифорнийская чайкаМорская чайка Научная классификация Домен:ЭукариотыЦарство:ЖивотныеПодцарство:ЭуметазоиБез ранга:Двусторонне-симметричныеБез ранга:Вторич...

 

この記事は検証可能な参考文献や出典が全く示されていないか、不十分です。出典を追加して記事の信頼性向上にご協力ください。(このテンプレートの使い方)出典検索?: コルク – ニュース · 書籍 · スカラー · CiNii · J-STAGE · NDL · dlib.jp · ジャパンサーチ · TWL(2017年4月) コルクを打ち抜いて作った瓶の栓 コルク(木栓、�...

 

Masters Rugby LeagueHighest governing bodyRugby League International FederationNicknamesMasters, Football, Footy, League, RugbyFirst played1992, New ZealandCharacteristicsContactVariedTeam members17 (13 on field + 4 interchange)Mixed-sexSingleTypeOutdoorEquipmentFootballVenueRugby league playing field Masters Rugby League is a derivative of rugby league for a wide age range of older, semi-retired and non-competitive players and officials.[1] Masters Rugby League started in Brisba...

American twin-engined cabin monoplane built 1962–1972 This article includes a list of general references, but it lacks sufficient corresponding inline citations. Please help to improve this article by introducing more precise citations. (October 2008) (Learn how and when to remove this message) PA-30 Twin Comanche 1967 Twin Comanche C/R Role Cabin monoplaneType of aircraft National origin United States Manufacturer Piper Aircraft First flight November 7, 1962[1] Produced 1961–1972...

 

Voce principale: ACF Fiorentina. AC FiorentinaStagione 1954-1955Sport calcio Squadra Fiorentina Allenatore Fulvio Bernardini All. in seconda Virgilio Felice Levratto Presidente Enrico Befani Serie A5º Maggiori presenzeCampionato: Segato (32) Miglior marcatoreCampionato: Virgili (15) StadioComunale 1953-1954 1955-1956 Si invita a seguire il modello di voce Questa voce raccoglie le informazioni riguardanti l'Associazione Calcio Fiorentina nelle competizioni ufficiali della stagione 1...

 

Röd stjärna över Kina, edisi Swedia dari buku tersebut pada 1974. Mao Zedong pada 1931. Red Star Over China, sebuah buku 1937 buatan Edgar Snow, adalah sebuah catatan dari Partai Komunis China yang ditulis ketika mereka menjadi tentara gerilya yang masih tidak banyak diketahui oleh orang-orang Barat. Bersama dengan The Good Earth (1931) karya Pearl Buck, buku tersebut merupakan buku paling berpengaruh tentang pengertian dan simpati Barat terhadap Tentara Merah China pada 1930an.[1]...

2016年美國總統選舉 ← 2012 2016年11月8日 2020 → 538個選舉人團席位獲勝需270票民意調查投票率55.7%[1][2] ▲ 0.8 %   获提名人 唐納·川普 希拉莉·克林頓 政党 共和黨 民主党 家鄉州 紐約州 紐約州 竞选搭档 迈克·彭斯 蒂姆·凱恩 选举人票 304[3][4][註 1] 227[5] 胜出州/省 30 + 緬-2 20 + DC 民選得票 62,984,828[6] 65,853,514[6]...

 

Leo SuryadinataLeo Suryadinata di Jakarta pada tahun 2023Lahir21 Februari 1941 (umur 83)Batavia, Hindia BelandaTempat tinggalSingapuraAlmamaterUniversitas NanyangUniversitas IndonesiaUniversitas MonashUniversitas OhioUniversitas AmerikaDikenal atasStudi Tionghoa-IndonesiaKarier ilmiahBidangSosiologi; Sinologi Leo Suryadinata Hanzi tradisional: 廖建裕 Alih aksara Mandarin - Hanyu Pinyin: Liào Jiàn Yù Min Nan - Romanisasi POJ: Liâu Kiàn-jū Nama Indonesia Indonesia: Liauw Kian-Djo...

 

Federasi Hoki Es IndonesiaOlahragaHoki esYurisdiksiNasionalSingkatanFHEIBerdiri20 Mei 2016; 7 tahun lalu (2016-05-20)AfiliasiIIHFTanggal afiliasi2016Kantor pusatJakartaKetua umumRonald Situmeang[1]Situs web resmifhei.co.id Federasi Hoki Es Indonesia (FHEI) adalah badan hoki es di Indonesia. Ia bergabung dengan Federasi Hoki Es Internasional (IIHF) sebagai anggota asosiasi pada tanggal 20 Mei 2016.[2] Sejarah Federasi Hoki Es Indonesia (FHEI) adalah organisasi olahraga hok...

Pekan Kebun Pohon PecanTaman Bersejarah Negara Lyndon B. Johnson Klasifikasi ilmiah Kerajaan: Plantae (tanpa takson): Tracheophyta (tanpa takson): Angiospermae (tanpa takson): Eudikotil (tanpa takson): Rosid Ordo: Fagales Famili: Juglandaceae Genus: Carya Spesies: C. illinoinensis Nama binomial Carya illinoinensis(Wangenh.) K.Koch Biji Pecan. Carya illinoinensis Pohon Pekan (Carya illinoinensis) adalah salah satu spesies tumbuhan berdaun majemuk yang berasal dari bagian tenggara Amerika...

 

Location of Malheur County in Oregon This list presents the full set of buildings, structures, objects, sites, or districts designated on the National Register of Historic Places in Malheur County, Oregon, and offers brief descriptive information about each of them. The National Register recognizes places of national, state, or local historic significance across the United States.[1] Out of over 90,000 National Register sites nationwide,[2] Oregon is home to over 2,000,[3...

 

Political movement in Greece This article is part of a series onPolitics of Greece Constitution Constitutional history Human rights Executive Head of state President of the Republic (list): Katerina Sakellaropoulou Presidential Departments Government Prime Minister (list): Kyriakos Mitsotakis Cabinet: Kyr. Mitsotakis II Legislature Speaker: Konstantinos Tasoulas Presidium Conference of Presidents Parliamentary committees Constituencies Apportionment Judiciary Supreme courts Special Highest C...

Pesta Olahraga Asia Tenggara 1997Tuan rumahJakarta IndonesiaJumlah negara10Jumlah atlet6007 (termasuk ofisial)Jumlah disiplin440 dari 34 cabang olahragaUpacara pembukaan11 Oktober 1997Upacara penutupan19 Oktober 1997Dibuka olehSoehartoPresiden Republik IndonesiaDitutup olehSoehartoPresiden Republik IndonesiaTempat utamaStadion SenayanSitus webPesta Olahraga Asia Tenggara 1997← Chiangmai 1995 Bandar Seri Begawan 1999 → Pesta Olahraga Negara-Negara Asia Tenggara 1997 (bahasa In...

 

У этого термина существуют и другие значения, см. Успенский район. район[1] / муниципальный район[2]Успенский район Флаг Герб 44°49′55″ с. ш. 41°22′56″ в. д.HGЯO Страна  Россия Входит в Краснодарский край Включает 10 муниципальных образований Адм. центр село У�...