SlideShare uma empresa Scribd logo
1 de 12
Modelagem Lógica
• Define a estrutura lógica entre tabelas,
relacionamentos e atributos do banco de
dados.
• É nesta modelagem que serão definidas os
padrões e nomenclaturas, chaves primárias e
chaves estrangeiras, sempre levando em conta
o modelo conceitual criado anteriormente.
Chaves e Índices
• Elemento fundamental para identificar um registro e são
empregados nas buscas de registros.
• Citamos dois principais tipos de chaves
– Chaves primárias
– Chaves estrangeiras
• Índices: são recursos utilizados por campos “não chaves”
que otimizam a busca ou recuperação de registros
• “Toda chave é um índice, mas nem todo índice é uma
chave”
Chave Primária (Primary Key)
• Atributo ou conjunto de atributos que diferenciam um
registro dos demais dentro de uma tabela.
• A coluna matrícula é a chave primária da tabela ALUNO
uma vez que através dela podemos distinguir de
maneira única um registro dos demais.
Chave Estrangeira (Foreign Key)
• Indica o relacionamento entre as tabelas.
• Normalmente será a chave primária de uma
das tabelas do relacionamento.
Restrições de Integridade
• Chave Primária: não pode conter valores nulos
(vazios) e não podem se repetir
• Chave Estrangeira: Os valores que estão na
chave estrangeira devem estar primeiramente
na chave primária da tabela referenciada.
Regras de Negócio
• Definidas como restrições, são situações que
devem ser implementadas pelo programador.
• Ex:
– Campos que serão chave primária deverão ter até
7 dígitos
Generalização / Especialização
• Quando somos generalista falamos de todos
• Quando somos especialistas separamos um
determinado grupo
CLIENTE
PESSOA JURÍDICA
PESSOA FÍSICA
É
1
1 1
Generalização / Especialização
Como identificar a chave primária?
• Você deve encontrar em seu modelo de
negócios um campo que deva ter
preenchimento obrigatório (não pode ser
nulo), não possa conter valores iguais
(repetidos) e de até 7 dígitos.
Como identificar a chave estrangeira?
• Deve-se analisar o grau do relacionamento:
• 1:N – Tabela lado N recebe a chave estrangeira
que virá da tabela lado 1
• N:N – O relacionamento recebe as chaves
estrangeiras que virão das tabelas relacionadas
com ele
• 1:1 – Tabela especialista recebe a chave primária
da tabela generalista e esta passa a ser chave
primária e estrangeira ao mesmo tempo.
Exemplo Chave Primária

Mais conteúdo relacionado

Destaque

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Destaque (20)

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 

Modelagem Lógica PPT.pptx

  • 2. • Define a estrutura lógica entre tabelas, relacionamentos e atributos do banco de dados. • É nesta modelagem que serão definidas os padrões e nomenclaturas, chaves primárias e chaves estrangeiras, sempre levando em conta o modelo conceitual criado anteriormente.
  • 3. Chaves e Índices • Elemento fundamental para identificar um registro e são empregados nas buscas de registros. • Citamos dois principais tipos de chaves – Chaves primárias – Chaves estrangeiras • Índices: são recursos utilizados por campos “não chaves” que otimizam a busca ou recuperação de registros • “Toda chave é um índice, mas nem todo índice é uma chave”
  • 4. Chave Primária (Primary Key) • Atributo ou conjunto de atributos que diferenciam um registro dos demais dentro de uma tabela. • A coluna matrícula é a chave primária da tabela ALUNO uma vez que através dela podemos distinguir de maneira única um registro dos demais.
  • 5. Chave Estrangeira (Foreign Key) • Indica o relacionamento entre as tabelas. • Normalmente será a chave primária de uma das tabelas do relacionamento.
  • 6. Restrições de Integridade • Chave Primária: não pode conter valores nulos (vazios) e não podem se repetir • Chave Estrangeira: Os valores que estão na chave estrangeira devem estar primeiramente na chave primária da tabela referenciada.
  • 7. Regras de Negócio • Definidas como restrições, são situações que devem ser implementadas pelo programador. • Ex: – Campos que serão chave primária deverão ter até 7 dígitos
  • 8. Generalização / Especialização • Quando somos generalista falamos de todos • Quando somos especialistas separamos um determinado grupo CLIENTE PESSOA JURÍDICA PESSOA FÍSICA É 1 1 1
  • 10. Como identificar a chave primária? • Você deve encontrar em seu modelo de negócios um campo que deva ter preenchimento obrigatório (não pode ser nulo), não possa conter valores iguais (repetidos) e de até 7 dígitos.
  • 11. Como identificar a chave estrangeira? • Deve-se analisar o grau do relacionamento: • 1:N – Tabela lado N recebe a chave estrangeira que virá da tabela lado 1 • N:N – O relacionamento recebe as chaves estrangeiras que virão das tabelas relacionadas com ele • 1:1 – Tabela especialista recebe a chave primária da tabela generalista e esta passa a ser chave primária e estrangeira ao mesmo tempo.