Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

relations 1

Status
Not open for further replies.

csniffer

Programmer
Apr 30, 2003
161
GB
how is one table Connected to another in MySQL? Is it purely hypothetical ie “id” in table1 and “id” in table2 are kept in sync by code or is there some command that says that this table is connected to that table by this “id”? please point me in the right direction. thx T

To err is human, to completely mess up takes a computer. [morning]
 
In MySQL relations are completely notional. Some database engines, such as Access, provide a mechanism for explicitly relating tables.

Some people claim that a foreign key (supported by MySQL >= 3.23.44 with InnoDB tables, does such a thing, but a foreign key is a constraint.

If column1 in tableA has a foreign key constraint to column3 in tableB, then values in column1 in tableA are constrained to those values that already appear in column3 of tableB.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
hmm... so how do u keep track of ur related tables

To err is human, to completely mess up takes a computer. [morning]
 
In several ways.

When you create a table, you can add a comment to any column. Something like "this column will relate to the column foo in table bar". You can change column comments with "ALTER TABLE" queries.

Careful, standardized column naming.

Copious notes in my program code.

Copious descriptions in my development notes.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
pk thx 4 that

To err is human, to completely mess up takes a computer. [morning]
 
"In MySQL relations are completely notional"

Can I remind you, sleipnir, that the word 'relation' means a special type of table. What we all call relational databases nowadays are not strictly relational because they all use tables rather than relations. A relation differs from a table in two ways:

1) All columns should have finite, defined domains.
2) There can never ever be a duplicate row in a relation.

The connections between relations/tables/entities are not 'relations'. Indeed, to my knowledge, there is no term for this in the relational model.

I know you are going to say that someone else has called relationships 'relations' but this exactly why I'm taking time to make this point.

 
1) All columns should have finite, defined domains.
2) There can never ever be a duplicate row in a relation.

but this could be said of mysql database if i am not mistaken.

Could you please explain a little more.

To err is human, to completely mess up takes a computer. [morning]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top