Hi,

As you can probably tell by now my knoweldge of MySQL is not very good.


I basically have two tables. One called userinformation and another called profiles

My userinformation table is like this:

CREATE TABLE `userinformation` (
  `id` int(11) NOT NULL auto_increment,
  `status` varchar(20) NOT NULL,
  `username` varchar(20) NOT NULL default '',
  `first_name` varchar(40) default NULL,
  `last_name` varchar(50) default NULL,
  `email` varchar(50) default NULL,
  `password` varchar(200) default NULL,
  `date_time` varchar(100) default NULL,
  `ip` varchar(50) NOT NULL,
  `activationkey` varchar(200) NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `username` (`username`),
  UNIQUE KEY `email` (`email`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ;

and my profiles table is like this

CREATE TABLE `profiles` (
  `id` int(11) NOT NULL auto_increment,
  `dob` varchar(50) collate latin1_general_ci NOT NULL,
  `gender` varchar(40) collate latin1_general_ci NOT NULL,
  `websiteurl` varchar(100) collate latin1_general_ci NOT NULL,
  `location` varchar(100) collate latin1_general_ci NOT NULL,
  `aboutme` varchar(3000) collate latin1_general_ci NOT NULL,
  `interests` varchar(3000) collate latin1_general_ci NOT NULL,
  `activities` varchar(3000) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=1 ;

I basically want to link my profiles table to my userinformation table. I want the profiles table to use and share the Id's from my userinformation table.

Reason why is the profiles table need to be linked to usersinformation table so users profiles and userinformation is linked.

Problem is i have searched all over the net and don't understand any of the information i have seen, nothing seems to explain how to do it properly.

I am not sure if it something to do with foreign key.

I not got a clue what query to use, both my tables already exist.

If someone could help it would be much appreciated.

Thank you,
genieuk

The

Recommended Answers

All 3 Replies

There is no way to create relationships between tables in the MyISAM engine, it all must be done in your business logic. Your tables must use InnoDB for foreign key constraints.

I'll let you look up the info on InnoDB foreign key constraints.

Hi,

I have been reading about that already, hence reason why i am asking for help, i am not sure how i change my tables to InnoDB and how to link the two tables together. Also it not a business site just a personal site.

so anyone can give instructions please do.

Thank you,
genieuk

No offense but I highly doubt we'll be able to teach you the intricacies of InnoDB any better than the web tutorials would. "Business Logic" is just a term meaning the logic controlling the site.

So I suggest you read a little deeper and maybe read it through a few times because at some point you're going to actually have to learn some of this stuff on your own. Being able to learn new things on your own is one of the most important skills for a programmer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.