Relational model: Difference between revisions

Content deleted Content added
Jtbwikiman (talk | contribs)
m Added link to DBMS page
m Disambiguating links to Object-orientation (link changed to Object-oriented programming) using DisamAssist.
 
(11 intermediate revisions by 10 users not shown)
Line 1:
{{short description|Database model}}
The '''relational model''' ('''RM''') is an approach to managing [[data]] using a [[Structure (mathematical logic)|structure]] and language consistent with [[first-order logic|first-order predicate logic]], first described in 1969 by English computer scientist [[Edgar F. Codd]],<ref>{{Citation | title = Derivability, Redundancy, and Consistency of Relations Stored in Large Data Banks | first = E.F | last = Codd | publisher = IBM | series = Research Report | year = 1969}}.</ref><ref name="codd1970">{{cite journal |last= Codd |first= E.F |year= 1970 |title= A Relational Model of Data for Large Shared Data Banks |series= Classics |url= http://www.acm.org/classics/nov95/toc.html |journal= [[Communications of the ACM]] |volume= 13 |issue= 6 |pages= 377–87 |doi= 10.1145/362384.362685 |s2cid= 207549016 |url-status= dead |archive-url= https://web.archive.org/web/20070612235326/http://www.acm.org/classics/nov95/toc.html |archive-date= 2007-06-12 |doi-access= free }}</ref> where all data isare represented in terms of [[tuple]]s, grouped into [[relation (database)|relation]]s. A database organized in terms of the relational model is a [[relational database]].
 
The purpose of the relational model is to provide a [[Declarative programming|declarative]] method for specifying data and queries: users directly state what information the database contains and what information they want from it, and let the [[database management system|database management system software]] take care of describing data structures for storing the data and retrieval procedures for answering queries.
Line 7:
 
== History ==
The relational model was developed by [[Edgar F. Codd]] as a general model of data, and subsequently promoted by [[Christopher J. Date|Chris Date]] and [[Hugh Darwen]] among others. In their 1995 ''The Third Manifesto'', Date and Darwen try to demonstrate how the relational model can accommodate certain "desired" [[Object-oriented programming|object-oriented]] features.<ref>{{Cite web |title=Did Date and Darwen's "Third Manifesto" have a lasting impact? |url=https://cs.stackexchange.com/questions/99350/did-date-and-darwens-third-manifesto-have-a-lasting-impact |access-date=2024-08-03 |website=Computer Science Stack Exchange |language=en}}</ref>
 
=== Extensions ===
Line 17:
[[File:Relational database terms.svg|thumb|A relation with 5 attributes (its degree) and 4 tuples (its cardinality) can be visualized as a table with 5 columns and 4 rows. However, unlike rows and columns in a table, a relation's attributes and tuples are unordered.]]
 
A ''relation'' consists of a ''heading'' and a ''body''. The heading defines a [[Set (mathematics)|set]] of ''attributes'', each with a ''name'' and ''data type'' (sometimes called a ''___domain''). The number of attributes in this set is the relation's ''degree'' or ''[[arity]]''. The body is a set of ''tuples''. A tuple is a collection of ''n'' ''values'', where ''n'' is the relation's degree, and each value in the tuple corresponds to a unique attribute.<ref>{{refnCite web |groupdate=nb2023-02-12 |Despite its name, a ''tuple''title=Tuple in theDBMS relational model is not a mathematical [[tuple]]|url=https://www. In mathematics, the elements of a geeksforgeeks.org/tuple are ordered. In the relational model, attributes are unordered, so the corresponding elements -in-dbms/ a|access-date=2024-08-03 tuple|website=GeeksforGeeks are also unordered.|language=en-US}}</ref> The number of tuples in this set is the relation's ''[[cardinality]]''.<ref name="professionals"/>{{rp|17–22}}
 
Relations are represented by ''relational [[Variable (computer science)|variables]]'' or ''relvars'', which can be reassigned.<ref name="professionals"/>{{rp|22–24}} A ''[[database]]'' is a collection of relvars.<ref name="professionals"/>{{rp|112–113}}
Line 40:
{{main|Foreign key}}
 
A ''foreign key'' is a subset of attributes ''{A}'' in a relation ''R<sub>1</sub>'' that corresponds with a key of another relation ''R<sub>2</sub>'', with the property that the [[Projection (relational algebra)|projection]] of ''R<sub>1</sub>'' on ''{A}'' is a subset of the projection of ''R<sub>2</sub>'' on ''{A}''. In other words, if a tuple in ''R<sub>1</sub>'' contains values for a foreign key, there must be a corresponding tuple in ''R<sub>2</sub>'' containing the same values for the corresponding key.<ref name="professionals"/>{{rp|34}}
 
=== Relational operations ===
Line 217:
''Datalog'' is a database definition language, which combines a relational view of data, as in the relational model, with a logical view, as in [[logic programming]]. Whereas relational databases use a relational calculus or relational algebra, with [[Relational database#Relational operations|relational operations]], such as ''union'', ''intersection'', ''set difference'' and ''cartesian product'' to specify queries, Datalog uses logical connectives, such as ''if'', ''or'', ''and'' and ''not'' to define relations as part of the database itself.
 
In contrast with the relational model, which cannot expressiveexpress recursive queries without introducing a least-fixed-point operator,<ref>Aho, A.V. and Ullman, J.D., 1979, January. Universality of data retrieval languages. In Proceedings of the 6th ACM SIGACT-SIGPLAN symposium on Principles of programming languages (pp. 110-119).</ref> recursive relations can be defined in Datalog, without introducing any new logical connectives or operators.
 
== See also ==
Line 246:
* {{Citation | publisher = Handle | title = Feasibility of a set-theoretic data structure: a general structure based on a reconstituted definition of relation | last = Childs | year = 1968 | type = research| hdl = 2027.42/4164 }} cited in Codd's 1970 paper.
* {{Citation | last = Darwen | first = Hugh | url = http://www.thethirdmanifesto.com/ | title = The Third Manifesto (TTM)}}.
* {{curlie|Computers/Software/Databases/Relational|Relational Databases}}
* {{Citation | contribution-url = http://c2.com/cgi/wiki?RelationalModel | contribution = Relational Model | title = C2}}.
* {{Citation | url = http://blogs.sun.com/bblfish/entry/why_binary_relations_beat_tuples | title = Binary relations and tuples compared with respect to the semantic web | publisher = Sun | type = [[World Wide Web]] log}}.
Line 258 ⟶ 257:
[[Category:Articles with example pseudocode]]
[[Category:Programming paradigms]]
[[Category:Database management systems]]