24
1 Converter MER para o Modelo Relacional e Popular tabelas criadas Adão de Melo Neto

Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

  • Upload
    others

  • View
    81

  • Download
    3

Embed Size (px)

Citation preview

Page 1: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

1

Converter MER para o

Modelo Relacional

e

Popular tabelas criadas

Adão de Melo Neto

Page 2: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

CONVERSÃO

MER PARA O RELACIONAL

2

Page 3: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

3

CONVERSÃO DE ENTIDADE

Page 4: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

CONVERSÃO DE RELACIONAMENTOS

RELACIONAMENTO N:N CRIAR TABELA PRÓPRIA PARA RELACIONAMENTO

RELACIONAMENTO 1:N CRIAÇÃO DE COLUNA(S) ADICIONAL(IS) EM TABELA

RELACIONAMENTO 1:1 FUSÃO DE TABELAS

RELACIONAMENTO TERNÁRIO

GENERALIZAÇÃO/ESPECIALIZAÇÃO

AUTORELACIONAMENTO

GENERALIZAÇÃO/ESPECIALIZAÇÃO

Page 5: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

5

Regra PráticaRELACIONAMENTO N:NCRIAÇÃO DE TABELA PRÓPRIA PARA O RELACIONAMENTO

Page 6: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

É criada uma TABELA para o Relacionamento contendo:

Colunas correspondentes aos identificadores das tabelas relacionadas (chaves estrangeiras)

Colunas correspondentes ao atributos do relacionamento (caso existam)

Chave Primária

É formada pela concatenação das colunas correspondentes aos identificadores das tabelas relacionadas (chaves estrangeiras)

RELACIONAMENTO N:NCRIAÇÃO DE TABELA PRÓPRIA PARA O RELACIONAMENTO

Page 7: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

RELACIONAMENTO N:NCRIAÇÃO DE TABELA PRÓPRIA PARA O RELACIONAMENTO

Page 8: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

8

Regra PráticaRELACIONAMENTO 1:NADIÇÃO DE COLUNA(S) ADICIONAL(IS) EM TABELA

Page 9: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

9

Entidade com cardinalidade máxima igual a 1 recebe:

Atributo identificador da Entidade Relacionada

Colunas correspondentes ao atributos do relacionamento

(caso existam)

RELACIONAMENTO 1:NADIÇÃO DE COLUNA(S) ADICIONAL(IS) EM TABELA

Page 10: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

RELACIONAMENTO 1:NADIÇÃO DE COLUNA(S) ADICIONAL(IS) EM TABELA

Page 11: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

11

RELACIONAMENTO 1:1FUSÃO DE TABELAS

Page 12: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

12

Todas colunas de uma tabela são movidas para outra tabela

A tabela que cedeu colunas deixa de existir

Colunas correspondentes aos atributos do relacionamento são movidos para tabela resultante

Chave primária desta tabela permanece inalterada

RELACIONAMENTO 1:1FUSÃO DE TABELAS

Page 13: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

RELACIONAMENTO 1:1FUSÃO DE TABELAS

Page 14: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

Criar uma nova tabela onde a chave primária consiste na concatenação

das chaves primárias das outras entidades e que tenha como atributo os

atributos dos relacionamentos (caso existam)

Instituições (Sigla) Projetos (Número)Pesquisadores (CPF)Pesquisa (Sigla, Número,CPF, DataInício)

RELACIONAMENTO TERNÁRIOCRIAÇÃO DE TABELA PRÓPRIA PARA O RELACIONAMENTO

Page 15: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave
Page 16: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

16

CONVERSÃO DE UM AUTO-RELACIONAMENTO

(adição de coluna)

Page 17: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

Criar uma Tabela única adicionando também um campo

denominado tipo (caso não exista)

SERVIDORES (CPF, Nome, Tipo, Função, Titulação, Categoria)

GENERALIZAÇÃO/ESPECIALIZAÇÃO

Page 18: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

18

AGREGAÇÃO

Page 19: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave
Page 20: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

FAÇA CONVERSÃO E POPULE AS TABELAS

RESULTADO FINAL da CONVERSÃO

Page 21: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

PASSO 01 – CONVERTER ENTIDADES EM TABELAS

1) MÉDICOS (CRM, SALARIO, NOME, ESPECIALIDADE)

2) PACIENTES (CPF, NOME, TELEFONE, ENDEREÇO, RG)

3) QUARTOS (NÚMERO, ANDAR)

Page 22: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave
Page 23: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave

RESULTADO FINAL

Page 24: Converter MER para o Modelo Relacional e Popular tabelas ...adao/AULA01BD3B2017F.pdf · FUSÃO DE TABELAS. RELACIONAMENTO 1:1 FUSÃO DE TABELAS Criar uma nova tabela onde a chave