Misplaced Pages

Associative entity

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.

An associative entity is a term used in relational and entity–relationship theory. A relational database requires the implementation of a base relation (or base table ) to resolve many-to-many relationships . A base relation representing this kind of entity is called, informally, an associative table .

#119880

50-424: As mentioned above, associative entities are implemented in a database structure using associative tables, which are tables that can contain references to columns from the same or different database tables within the same database. An associative (or junction) table maps two or more tables together by referencing the primary keys (PK) of each data table. In effect, it contains a number of foreign keys (FK), each in

100-480: A primary key is a designated attribute ( column ) that can reliably identify and distinguish between each individual record in a table . The database creator can choose an existing unique attribute or combination of attributes from the table (a natural key ) to act as its primary key, or create a new attribute containing a unique ID that exists solely for this purpose (a surrogate key ). Examples of natural keys that could be suitable primary keys include data that

150-645: A many-to-one relationship from the junction table to the individual data tables. The PK of the associative table is typically composed of the FK columns themselves. Associative tables are colloquially known under many names, including association table , bridge table , cross-reference table , crosswalk , intermediary table , intersection table , join table , junction table , link table , linking table , many-to-many resolver , map table , mapping table , pairing table , pivot table (as used in Laravel —not to be confused with

200-399: A new row is written to the table, a new unique value for the primary key is generated; this is the key that the system uses primarily for accessing the table. System performance is optimized for PKs. Other, more natural keys may also be identified and defined as alternate keys (AK). Often several columns are needed to form an AK (this is one reason why a single integer column is usually made

250-445: A relational database system is composed of Codd's 12 rules . However, no commercial implementations of the relational model conform to all of Codd's rules, so the term has gradually come to describe a broader class of database systems, which at a minimum: In 1974, IBM began developing System R , a research project to develop a prototype RDBMS. The first system sold as an RDBMS was Multics Relational Data Store (June 1976). Oracle

300-455: A single relation, even though they may grab information from several relations. Also, derived relations can be used as an abstraction layer . A domain describes the set of possible values for a given attribute, and can be considered a constraint on the value of the attribute. Mathematically, attaching a domain to an attribute means that any value for the attribute must be an element of the specified set. The character string "ABC" , for instance,

350-554: A system. For increased security, the system design may grant access to only the stored procedures and not directly to the tables. Fundamental stored procedures contain the logic needed to insert new and update existing data. More complex procedures may be written to implement additional rules and logic related to processing or selecting the data. The relational database was first defined in June 1970 by Edgar Codd , of IBM's San Jose Research Laboratory . Codd's view of what qualifies as an RDBMS

400-414: A tuple (restricting combinations of attributes) or to an entire relation. Since every attribute has an associated domain, there are constraints ( domain constraints ). The two principal rules for the relational model are known as entity integrity and referential integrity . Every relation /table has a primary key, this being a consequence of a relation being a set . A primary key uniquely specifies

450-476: A tuple within a table. While natural attributes (attributes used to describe the data being entered) are sometimes good primary keys, surrogate keys are often used instead. A surrogate key is an artificial attribute assigned to an object which uniquely identifies it (for instance, in a table of information about students at a school they might all be assigned a student ID in order to differentiate them). The surrogate key has no intrinsic (inherent) meaning, but rather

500-521: Is a relational database management system ( RDBMS ). Many relational database systems are equipped with the option of using SQL (Structured Query Language) for querying and updating the database. The concept of relational database was defined by E. F. Codd at IBM in 1970. Codd introduced the term relational in his research paper "A Relational Model of Data for Large Shared Data Banks". In this paper and later papers, he defined what he meant by relation . One well-known definition of what constitutes

550-400: Is a choice of a candidate key (a minimal superkey ); any other candidate key is an alternate key . In relational database terms, a primary key does not differ in form or function from a key that isn't primary. In practice, various motivations may determine the choice of any one key as primary over another. The designation of a primary key may indicate the "preferred" identifier for data in

SECTION 10

#1732855232120

600-417: Is already by definition unique to all items in the table such as a national identification number attribute for person records, or the combination of a very precise timestamp attribute with a very precise location attribute for event records. More formally, a primary key is a specific choice of a minimal set of attributes that uniquely specify a tuple ( row ) in a relation (table). A primary key

650-503: Is analogous to using the index of a book to go directly to the page on which the information you are looking for is found, so that you do not have to read the entire book to find what you are looking for. Relational databases typically supply multiple indexing techniques, each of which is optimal for some combination of data distribution, relation size, and typical access pattern. Indices are usually implemented via B+ trees , R-trees , and bitmaps . Indices are usually not considered part of

700-497: Is not in the integer domain, but the integer value 123 is. Another example of domain describes the possible values for the field "CoinFace" as ("Heads","Tails"). So, the field "CoinFace" will not accept input values like (0,1) or (H,T). Constraints are often used to make it possible to further restrict the domain of an attribute. For instance, a constraint can restrict a given integer attribute to values between 1 and 10. Constraints provide one method of implementing business rules in

750-423: Is not valid in a unique column). Alternate keys may be used like the primary key when doing a single-table select or when filtering in a where clause, but are not typically used to join multiple tables. RDBMS A relational database ( RDB ) is a database based on the relational model of data, as proposed by E. F. Codd in 1970. A database management system used to maintain relational databases

800-484: Is obviously preferred. A surrogate key may be used as the primary key to avoid giving one candidate key artificial primacy over the others. Since primary keys exist primarily as a convenience to the programmer, surrogate primary keys are often used, in many cases exclusively, in database application design. Due to the popularity of surrogate primary keys, many developers and in some cases even theoreticians have come to regard surrogate primary keys as an inalienable part of

850-449: Is summarized in Codd's 12 rules . A relational database has become the predominant type of database. Other models besides the relational model include the hierarchical database model and the network model . The table below summarizes some of the most important relational database terms and the corresponding SQL term: In a relational database, a relation is a set of tuples that have

900-446: Is useful through its ability to uniquely identify a tuple. Another common occurrence, especially in regard to N:M cardinality is the composite key . A composite key is a key made up of two or more attributes within a table that (together) uniquely identify a record. Foreign key refers to a field in a relational table that matches the primary key column of another table. It relates the two keys. Foreign keys need not have unique values in

950-679: The SQL standard mainly as a convenience to the application programmer. Primary keys can be an integer that is incremented, a universally unique identifier (UUID) or can be generated using Hi/Lo algorithm . Primary keys are defined in the ISO SQL Standard , through the PRIMARY KEY constraint. The syntax to add such a constraint to an existing table is defined in SQL:2003 like this: The primary key can also be specified directly during table creation. In

1000-417: The normal forms . Connolly and Begg define database management system (DBMS) as a "software system that enables users to define, create, maintain and control access to the database". RDBMS is an extension of that initialism that is sometimes used when the underlying database is relational. An alternative definition for a relational database management system is a database management system (DBMS) based on

1050-569: The relational model . Most databases in widespread use today are based on this model. RDBMSs have been a common option for the storage of information in databases used for financial records, manufacturing and logistical information, personnel data, and other applications since the 1980s. Relational databases have often replaced legacy hierarchical databases and network databases , because RDBMS were easier to implement and administer. Nonetheless, relational stored data received continued, unsuccessful challenges by object database management systems in

SECTION 20

#1732855232120

1100-496: The 1980s and 1990s, (which were introduced in an attempt to address the so-called object–relational impedance mismatch between relational databases and object-oriented application programs), as well as by XML database management systems in the 1990s. However, due to the expanse of technologies, such as horizontal scaling of computer clusters , NoSQL databases have recently become popular as an alternative to RDBMS databases. Distributed Relational Database Architecture (DRDA)

1150-445: The PK). Both PKs and AKs have the ability to uniquely identify a row within a table. Additional technology may be applied to ensure a unique ID across the world, a globally unique identifier , when there are broader system requirements. The primary keys within a database are used to define the relationships among the tables. When a PK migrates to another table, it becomes a foreign key (FK) in

1200-460: The SQL Standard, primary keys may consist of one or multiple columns. Each column participating in the primary key is implicitly defined as NOT NULL. Note that some RDBMS require explicitly marking primary key columns as NOT NULL . If the primary key consists only of a single column, the column can be marked as such using

1250-438: The basis of interaction among these tables. These relationships can be modelled as an entity-relationship model . In order for a database management system (DBMS) to operate efficiently and accurately, it must use ACID transactions . Part of the programming within a RDBMS is accomplished using stored procedures (SPs). Often procedures can be used to greatly reduce the amount of information transferred within and outside of

1300-402: The columns represent values attributed to that instance (such as address or price). For example, each row of a class table corresponds to a class, and a class corresponds to multiple students, so the relationship between the class table and the student table is "one to many" Each row in a table has its own unique key. Rows in a table can be linked to rows in other tables by adding a column for

1350-617: The current understanding on the relational model, as expressed by Christopher J. Date , Hugh Darwen and others), it is not relational. This view, shared by many theorists and other strict adherents to Codd's principles, would disqualify most DBMSs as not relational. For clarification, they often refer to some RDBMSs as truly-relational database management systems (TRDBMS), naming others pseudo-relational database management systems (PRDBMS). As of 2009, most commercial relational DBMSs employ SQL as their query language . Alternative query languages have been proposed and implemented, notably

1400-401: The database and support subsequent data use within the application layer. SQL implements constraint functionality in the form of check constraints . Constraints restrict the data that can be stored in relations . These are usually defined using expressions that result in a Boolean value, indicating whether or not the data satisfies the constraint. Constraints can apply to single attributes, to

1450-469: The database, as they are considered an implementation detail, though indices are usually maintained by the same group that maintains the other parts of the database. The use of efficient indexes on both primary and foreign keys can dramatically improve query performance. This is because B-tree indexes result in query times proportional to log(n) where n is the number of rows in a table and hash indexes result in constant time queries (no size dependency as long as

1500-399: The following syntax: In some circumstances the natural key that uniquely identifies a tuple in a relation may be cumbersome to use for software development. For example, it may involve multiple columns or large text fields. In such cases, a surrogate key can be used instead as the primary key. In other situations there may be more than one candidate key for a relation, and no candidate key

1550-468: The immutability of primary key values during database and application design. Some database systems even imply that values in primary key columns cannot be changed using the UPDATE SQL statement. Typically, one candidate key is chosen as the primary key. Other candidate keys become alternate keys, each of which may have a UNIQUE constraint assigned to it in order to prevent duplicates (a duplicate entry

Associative entity - Misplaced Pages Continue

1600-467: The junction table: This will return a list of all users and their permissions. Inserting into a junction table involves multiple steps: first inserting into the main table(s), then updating the junction table. Using foreign keys, the database will automatically dereference the values of the UserPermissions table to their own tables. Primary key In the relational model of databases ,

1650-519: The original eight including relational comparison operators and extensions that offer support for nesting and hierarchical data, among others. Normalization was first proposed by Codd as an integral part of the relational model. It encompasses a set of procedures designed to eliminate non-simple domains (non-atomic values) and the redundancy (duplication) of data, which in turn prevents data manipulation anomalies and loss of data integrity. The most common forms of normalization applied to databases are called

1700-500: The other table. When each cell can contain only one value and the PK migrates into a regular entity table, this design pattern can represent either a one-to-one or one-to-many relationship. Most relational database designs resolve many-to-many relationships by creating an additional table that contains the PKs from both of the other entity tables – the relationship becomes an entity;

1750-446: The pre-1996 implementation of Ingres QUEL . A relational model organizes data into one or more tables (or "relations") of columns and rows , with a unique key identifying each row. Rows are also called records or tuples . Columns are also called attributes. Generally, each table/relation represents one "entity type" (such as customer or product). The rows represent instances of that type of entity (such as "Lee" or "chair") and

1800-458: The referencing relation. A foreign key can be used to cross-reference tables, and it effectively uses the values of attributes in the referenced relation to restrict the domain of one or more attributes in the referencing relation. The concept is described formally as: "For all tuples in the referencing relation projected over the referencing attributes, there must exist a tuple in the referenced relation projected over those same attributes such that

1850-479: The relational data model. This is largely due to a migration of principles from the object-oriented programming model to the relational model, creating the hybrid object–relational model. In the ORM like active record pattern , these additional restrictions are placed on primary keys: However, neither of these restrictions is part of the relational model or any SQL standard. Due diligence should be applied when deciding on

1900-400: The relational model were from: The most common definition of an RDBMS is a product that presents a view of data as a collection of rows and columns, even if it is not based strictly upon relational theory . By this definition, RDBMS products typically implement some but not all of Codd's 12 rules. A second school of thought argues that if a database does not implement all of Codd's rules (or

1950-594: The relevant part of the index fits into memory). Queries made against the relational database, and the derived relvars in the database are expressed in a relational calculus or a relational algebra . In his original relational algebra, Codd introduced eight relational operators in two groups of four operators each. The first four operators were based on the traditional mathematical set operations : The remaining operators proposed by Codd involve special operations specific to relational databases: Other operators have been introduced or proposed since Codd's introduction of

2000-399: The resolution table is then named appropriately and the two FKs are combined to form a PK. The migration of PKs to other tables is the second major reason why system-assigned integers are used normally as PKs; there is usually neither efficiency nor clarity in migrating a bunch of other types of columns. Relationships are a logical connection between different tables (entities), established on

2050-435: The same attributes . A tuple usually represents an object and information about that object. Objects are typically physical objects or concepts. A relation is usually described as a table , which is organized into rows and columns . All the data referenced by an attribute are in the same domain and conform to the same constraints. The relational model specifies that the tuples of a relation have no specific order and that

Associative entity - Misplaced Pages Continue

2100-460: The standard declarative SQL syntax. Stored procedures are not part of the relational database model, but all commercial implementations include them. An index is one way of providing quicker access to data. Indices can be created on any combination of attributes on a relation . Queries that filter using those attributes can find matching tuples directly using the index (similar to Hash table lookup), without having to check each tuple in turn. This

2150-557: The table, or that the primary key is to be used for foreign key references from other tables or it may indicate some other technical rather than semantic feature of the table. Some languages and software have special syntax features that can be used to identify a primary key as such (e.g. the PRIMARY KEY constraint in SQL). The relational model, as expressed through relational calculus and relational algebra, does not distinguish between primary keys and other kinds of keys. Primary keys were added to

2200-767: The tuple contains a candidate or primary key then obviously it is unique; however, a primary key need not be defined for a row or record to be a tuple. The definition of a tuple requires that it be unique, but does not require a primary key to be defined. Because a tuple is unique, its attributes by definition constitute a superkey . All data are stored and accessed via relations . Relations that store data are called "base relations", and in implementations are called "tables". Other relations do not store data, but are computed by applying relational operations to other relations. These relations are sometimes called "derived relations". In implementations these are called " views " or "queries". Derived relations are convenient in that they act as

2250-473: The tuples, in turn, impose no order on the attributes. Applications access data by specifying queries, which use operations such as select to identify tuples, project to identify attributes, and join to combine relations. Relations can be modified using the insert , delete , and update operators. New tuples can supply explicit values or be derived from a query. Similarly, queries identify tuples for updating or deleting. Tuples by definition are unique. If

2300-401: The unique key of the linked row (such columns are known as foreign keys ). Codd showed that data relationships of arbitrary complexity can be represented by a simple set of concepts. Part of this processing involves consistently being able to select or modify one and only one row in a table. Therefore, most physical implementations have a unique primary key (PK) for each row in a table. When

2350-403: The use of pivot table in spreadsheets ), or transition table . An example of the practical use of an associative table would be to assign permissions to users. There can be multiple users, and each user can be assigned zero or more permissions. Individual permissions may be granted to one or more users. A SELECT -statement on a junction table usually involves joining the main table with

2400-689: The values in each of the referencing attributes match the corresponding values in the referenced attributes." A stored procedure is executable code that is associated with, and generally stored in, the database. Stored procedures usually collect and customize common operations, like inserting a tuple into a relation , gathering statistical information about usage patterns, or encapsulating complex business logic and calculations. Frequently they are used as an application programming interface (API) for security or simplicity. Implementations of stored procedures on SQL RDBMS's often allow developers to take advantage of procedural extensions (often vendor-specific) to

2450-618: Was designed by a workgroup within IBM in the period 1988 to 1994. DRDA enables network connected relational databases to cooperate to fulfill SQL requests. The messages, protocols, and structural components of DRDA are defined by the Distributed Data Management Architecture . According to DB-Engines , in January 2023 the most popular systems on the db-engines.com web site were: According to research company Gartner , in 2011,

2500-412: Was released in 1979 by Relational Software, now Oracle Corporation . Ingres and IBM BS12 followed. Other examples of an RDBMS include IBM Db2 , SAP Sybase ASE , and Informix . In 1984, the first RDBMS for Macintosh began being developed, code-named Silver Surfer, and was released in 1987 as 4th Dimension and known today as 4D. The first systems that were relatively faithful implementations of

#119880