Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Relational database
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Keys== 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 the unique key of the linked row (such columns are known as [[foreign key]]s). Codd showed that data relationships of arbitrary complexity can be represented by a simple set of concepts.<ref name="codd" /> 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 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 key]]s may also be identified and defined as [[alternate key]]s (AK). Often several columns are needed to form an AK (this is one reason why a single integer column is usually made 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 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 (data model)|one-to-one]] or [[One-to-many (data model)|one-to-many]] relationship. Most relational database designs resolve [[Many-to-many (data model)|many-to-many]] relationships by creating an additional table that contains the PKs from both of the other entity tables{{snd}} the relationship becomes an entity; 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=== Relationships are a logical connection between different tables (entities), established on the basis of interaction among these tables. These relationships can be modelled as an [[Entity–relationship model|entity-relationship model]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)