Beta Phase: Square45 is currently in beta testing. Expect some features or content to be incomplete or missing.
45

Relational Model

Field: Databases

An approach to managing data using a structure and language consistent with first-order predicate logic.

Sequence of Expressions

Definition

Relation Schema

Define a relation schema RR as a tuple Schema(R)=(A1,A2,...,An)\text{Schema}(R) = (A_1, A_2, \text{...}, A_n), where AiA_i is the name of the ii-th attribute, and Dom(Ai)\text{Dom}(A_i) is the specified domain (set of allowed values) for that attribute. The set of all possible tuples for RR is the Cartesian product of the domains: Tuples(R) = Dom(A1)× Dom(A2)× ...× Dom(An)\text{Tuples}(R) \text{ } = \text{ } \text{Dom}(A_1) \times \text{ } \text{Dom}(A_2) \times \text{ } \text{...} \times \text{ } \text{Dom}(A_n).
Definition

Tuple

Let RR be a relation with schema Schema(R)=(A1,...,An)\text{Schema}(R) = (A_1, \text{...}, A_n). A tuple tt is an ordered nn-tuple of values, t=(v1,v2,...,vn)t = (v_1, v_2, \text{...}, v_n), such that for every i in [1,n]i \text{ } \text{in } [1, n], the value viv_i belongs to the domain Dom(Ai)\text{Dom}(A_i). Formally, t is an element of  Dom(A1)× ...× Dom(An)t \text{ } \text{is an element of } \text{ } \text{Dom}(A_1) \times \text{ } \text{...} \times \text{ } \text{Dom}(A_n).
Definition

Primary Key

Let RR be a relation with schema (A1,...,An)(A_1, \text{...}, A_n). A set of attributes K= Schema(K)=(Ai1,...,Aik)K = \text{ } \text{Schema}(K) = (A_{i_1}, \text{...}, A_{i_k}) is a candidate key if and only if the projection of RR onto KK, denoted  projK(R)\text{ } \text{proj}_K(R), is a set of unique tuples. That is, for any two tuples t1,t2 in Rt_1, t_2 \text{ } \text{in } R, if  projK(t1)= projK(t2)\text{ } \text{proj}_K(t_1) = \text{ } \text{proj}_K(t_2), then t1=t2t_1 = t_2.
Let G=(V,E)G = (V, E) be a graph representing the conceptual model. The set of vertices VV is partitioned into VEV_E (Entities) and VRV_R (Relationships). For any vVEv \notin V_E, vv is associated with a set of attributes A(v)A(v). The set of edges EE connects vertices, where an edge e=(vi,vj)e = (v_i, v_j) is labeled by a relationship type RR, and the cardinality of ee is ek|e| \rightarrow k, indicating the arity of the relationship.
Let L\text{L} be a first-order language defined by a set of predicate symbols P=P1,P2,...\text{P} = \text{P}_1, \text{P}_2, \text{...} and a set of function symbols F\text{F}. A formula A\text{A} is constructed recursively: A::=p(xˉ)  ¬ A1  A2 x A  A  A\text{A} ::= p(\bar{x}) \text{ } | \text{ } \neg \text{A} \text{ } | \text{ } \text{A}_1 \text{ } \text{ } \text{A}_2 \text{ } | \forall x \text{ } \text{A} \text{ } | \text{ } \text{A} \text{ } \rightarrow \text{ } \text{A}. The truth value of A\text{A} is evaluated relative to an interpretation I\text{I} mapping symbols in L\text{L} to sets and functions over a domain D\text{D}.