Hey,
I just got a new project from a client and I can’t change the database schema. I ever created my on tables ans schemas so I never got this type of problem. I can’t figure out how to establish the relation. If someone can help I will be glad.
3 tables
Has PK
[sql]CREATE TABLE IF NOT EXISTS celebridade (
id smallint(5) unsigned NOT NULL AUTO_INCREMENT,
titulo varchar(255) COLLATE latin1_general_ci NOT NULL,
nome varchar(255) COLLATE latin1_general_ci NOT NULL,
…
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=842 ;[/sql]
Has PK
[sql]CREATE TABLE IF NOT EXISTS noticias (
id int(11) NOT NULL AUTO_INCREMENT,
titulo text COLLATE utf8_unicode_ci NOT NULL,
descricao text COLLATE utf8_unicode_ci NOT NULL,
…
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=622 ;[/sql]
No PK
[sql]CREATE TABLE IF NOT EXISTS noticia_celebridade (
noticia int(11) NOT NULL,
celebridade int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;[/sql]
I need to set up the relation between "noticia" x "noticia_celebridade" and get the correct "celebridade"
"celebridade" HAS MANY "noticia"
I make my self clear?
Thanks All