Ir para conteúdo
Fórum Script Brasil
  • 0

Estrutura De Tabelas (me Ajudem)


Guest gilroberto

Pergunta

Guest gilroberto

wink.gif Estou precisando criar um Banco de Dados com Categorias e Subcategorias, exemplo:

CENTRO -> ALIMENTAÇÃO -> Mc Donalds

ou seja, o Mc DOnalds pertence a categoria "alimentação" do bairro "centro" e assim por diante.

Criei uma tabela mas não está dando certo do jeito que quero.

-----------------------------------------------------------------------------------------------

#

# Table structure for table 'anunciantes'

#

drop table if exists anunciantes;

CREATE TABLE anunciantes (

anun_id int not null primary key auto_increment,

cat_id int not null default '0',

nome text NULL,

endereco text NOT NULL,

telefone text NOT NULL,

descricao text NOT NULL,

url text NULL,

email varchar(255) NULL,

responsavel varchar(255) NULL,

nasc varchar(255) NULL,

remote_ip varchar(40) NOT NULL,

UNIQUE KEY anun_id (anun_id),

KEY cat_id (cat_id)

);

# --------------------------------------------------------

#

# Table structure for table 'bairros'

#

drop table if exists bairros;

CREATE TABLE bairros (

bair_id int not null primary key auto_increment,

bairro text NULL,

UNIQUE KEY bair_id (bair_id)

);

# --------------------------------------------------------

#

# Table structure for table 'categorias'

#

drop table if exists categorias;

CREATE TABLE categorias (

cat_id int not null primary key auto_increment,

bair_id int(11) NOT NULL default '0',

categoria text NULL,

UNIQUE KEY cat_id (cat_id)

);

# --------------------------------------------------------

Peço que alguém possa ajudar a estruturar esta tabela, basta dizer como faço para inserir e pesquisar dados no MySql.

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

Visitante
Este tópico está impedido de receber novos posts.


  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...