SlideShare a Scribd company logo
1 of 15
NAME : MITALI MANIYAR
EN.NO.:150410107048
CLASS : SY CE-1
DEPT. : COMPUTER
Constraints, Keys,
Design issues , E-R diagrams
KEYS
A key is an attribute or set of attributes that uniquely identifies a tuple in a
relation/table.
Keys are used to access or sequence stored data and to create relationship between
different tables.
Types of Keys are:
1.Primary key
2.Foreign key
3.Super key
4.Candidate key
5.Unique key
• Primary Key – A primary is a column or set of columns in a table that uniquely
identifies tuples (rows) in that table.
• Super Key – A super key is a set of one of more columns (attributes) to uniquely
identify rows in a table.
• Candidate Key – A super key with no redundant attribute is known as candidate
key. With the help of primary key, candidate key can use to identify all other
tuples in table.
• Foreign Key – Foreign keys are the columns of a table that points to the primary
key of another table. They act as a cross-reference between tables.
• Unique Key – Unique key is a special case of primary key. It has a condition
that its value can be null while in primary key can’t have null value as input.
CONSTRAINT
• Constraints enforce limits to the data or type of data that can be
inserted/updated/deleted from a table. The whole purpose of constraints is to
maintain the data integrity during an update/delete/insert into a table. In this
tutorial we will learn several types of constraints that can be created in Relational
DBMS.
• Types of constraints
1.NOT NULL
2.UNIQUE
3.DEFAULT
4.CHECK
5.Key Constraints – PRIMARY KEY, FOREIGN KEY
Not Null
• NOT NULL constraint makes sure that a column
does not hold NULL value. When we don’t
provide value for a particular column while
inserting a record into a table, it takes NULL
value by default. By specifying NULL constraint,
we can be sure that a particular column(s)
cannot have NULL values.
Unique
• UNIQUE Constraint enforces a column or set of
columns to have unique values. If a column has
a unique constraint, it means that particular
column cannot have duplicate values in a table.
CREATE TABLE STUDENT(
ROLL_NO NUMBER NOT
NULL, STU_NAME
VARCHAR (35) NOT NULL,
STU_AGE NUMBER NOT
NULL, STU_ADDRESS
VARCHAR (235), PRIMARY
KEY (ROLL_NO) );
CREATE TABLE STUDENT(
ROLL_NO NUMBER NOT
NULL, STU_NAME VARCHAR
(35) NOT NULL UNIQUE,
STU_AGE NUMBER NOT
NULL, STU_ADDRESS
VARCHAR (35) UNIQUE,
PRIMARY KEY (ROLL_NO) );
Default
• The DEFAULT constraint provides a default value
to a column when there is no value provided
while inserting a record into a table.
Check
• This constraint is used for specifying range of
values for a particular column of a table. When
this constraint is being set on a column, it
ensures that the specified column must have the
value falling in the specified range.
CREATE TABLE STUDENT(
ROLL_NO NUMBER NOT NULL,
STU_NAME VARCHAR (35) NOT NULL,
STU_AGE NUMBER NOT NULL,
EXAM_FEE NUMBER DEFAULT 10000,
STU_ADDRESS VARCHAR (35) ,
PRIMARY KEY (ROLL_NO)
);
CREATE TABLE STUDENT(
ROLL_NO NUMBER NOT
NULL CHECK(ROLL_NO >1000),
STU_NAME VARCHAR (35)
NOT NULL,
STU_AGE NUMBER NOT
NULL,
EXAM_FEE NUMBER DEFAULT
10000,
STU_ADDRESS VARCHAR (35) ,
PRIMARY KEY (ROLL_NO)
);
KEY CONSTRAINTS
Primary Key
• Primary key uniquely identifies each record in a
table. It must have unique values and cannot
contain nulls. In the below example the ROLL_NO
field is marked as primary key, that means the
ROLL_NO field cannot have duplicate and null
values.
Foreign key
• Foreign keys are the columns of a table that
points to the primary key of another table. They
act as a cross-reference between tables.
CREATE TABLE STUDENT(
ROLL_NO NUMBER NOT NULL,
STU_NAME VARCHAR (35) NOT
NULL UNIQUE,
STU_AGE NUMBER NOT NULL,
STU_ADDRESS VARCHAR (35)
UNIQUE,
PRIMARY KEY (ROLL_NO)
);
ER DIAGRAMS
• An Entity Relationship Diagram (ERD) is a visual representation
of different data using conventions that describe how these
data are related to each other. For example, the elements
writer, novel, and consumer may be described using ER
diagrams this way.
• In the diagram, the elements inside rectangles are called
entities while the items inside diamonds denote the
relationships between entities.
ER DIAGRAM SYMBOL AND NOTATION
• There are three basic elements in an ER Diagram: entity,
attribute, relationship. There are more elements which are
based on the main elements. They are weak entity,
multivalued attribute, derived attribute, weak relationship
and recursive relationship.
Entity
• An entity can be a person, place, event, or object
that is relevant to a given system. For example, a
school system may include students, teachers,
major courses, subjects, fees, and other items.
Entities are represented in ER diagrams by a
rectangle and named using singular nouns.
• weak entity is an entity that depends on the
existence of another entity. In more technical terms
it can defined as an entity that cannot be identified
by its own attributes. It uses a foreign key combined
with its attributed to form the primary key.
Attributes
• An attribute is a property, trait, or characteristic of an
entity, relationship, or another attribute. For example,
the attribute Inventory Item Name is an attribute of the
entity Inventory Item. An entity can have as many
attributes as necessary. Meanwhile, attributes can also
have their own specific attributes. For example, the
attribute “customer address” can have the attributes
number, street, city, and state.
• There are composite attribute, multivalued attribute
and derived attribute .
Relationship
• A relationship describes how entities interact.
For example, the entity “carpenter” may be
related to the entity “table” by the relationship
“builds” or “makes”. Relationships are
represented by diamond shapes and are labelled
using verbs.
HOW TO DRAW E-R DIAGRAMS ?
• Identify all the relevant entities in a given system and determine the relationships among these
entities.
• An entity should appear only once in a particular diagram.
• Provide a precise and appropriate name for each entity, attribute, and relationship in the
diagram. Terms that are simple and familiar always beats vague, technical-sounding words. In
naming entities, remember to use singular nouns. However, adjectives may be used to
distinguish entities belonging to the same class (part-time employee and full time employee,
for example). Meanwhile attribute names must be meaningful, unique, system-independent,
and easily understandable.
• Remove vague, redundant or unnecessary relationships between entities.
• Never connect a relationship to another relationship.
DESIGN ISSUES
• It is not always clear whether an object is best expressed by an entity set or a relationship set.
• Two problems arise as a result of the replication: (1) the data are stored multiple times, wasting storage
space, and (2) updates potentially leave the data in an inconsistent state, where the values differ in two
relationships for attributes that are supposed to have the same value.
• Relationships in databases are often binary. Some relationships that appear to be nonbinary could
actually be better represented by several binary relationships.
ER diagram

More Related Content

What's hot

Keys in dbms
Keys in dbmsKeys in dbms
Keys in dbmsshalini s
 
Relational database management system
Relational database management systemRelational database management system
Relational database management systemPraveen Soni
 
Database Engineering: Part one
Database Engineering: Part oneDatabase Engineering: Part one
Database Engineering: Part oneChristoph Becher
 
Relational Model - An Introduction
Relational Model - An IntroductionRelational Model - An Introduction
Relational Model - An IntroductionRajeev Srivastava
 
Learn Database Design with MySQL - Chapter 5 - Design principles & normalization
Learn Database Design with MySQL - Chapter 5 - Design principles & normalizationLearn Database Design with MySQL - Chapter 5 - Design principles & normalization
Learn Database Design with MySQL - Chapter 5 - Design principles & normalizationEduonix Learning Solutions
 
Cardinality and participation constraints
Cardinality and participation constraintsCardinality and participation constraints
Cardinality and participation constraintsNikhil Deswal
 
Database constraints
Database constraintsDatabase constraints
Database constraintsHarry Potter
 
Intro to relational model
Intro to relational modelIntro to relational model
Intro to relational modelATS SBGI MIRAJ
 
Relational model
Relational modelRelational model
Relational modelRUpaliLohar
 
Referential integrity
Referential integrityReferential integrity
Referential integrityJubin Raju
 
Pokok bahasan #3a er modeling
Pokok bahasan #3a er modelingPokok bahasan #3a er modeling
Pokok bahasan #3a er modelingSlamet Widodo
 
2. relational model_150903
2. relational model_1509032. relational model_150903
2. relational model_150903Dika Handika
 
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization TechniquesNishant Munjal
 
Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1Eddyzulham Mahluzydde
 

What's hot (19)

Keys in dbms
Keys in dbmsKeys in dbms
Keys in dbms
 
Database design
Database designDatabase design
Database design
 
Relational database management system
Relational database management systemRelational database management system
Relational database management system
 
Database Engineering: Part one
Database Engineering: Part oneDatabase Engineering: Part one
Database Engineering: Part one
 
Relational Model - An Introduction
Relational Model - An IntroductionRelational Model - An Introduction
Relational Model - An Introduction
 
Learn Database Design with MySQL - Chapter 5 - Design principles & normalization
Learn Database Design with MySQL - Chapter 5 - Design principles & normalizationLearn Database Design with MySQL - Chapter 5 - Design principles & normalization
Learn Database Design with MySQL - Chapter 5 - Design principles & normalization
 
Sql Constraints
Sql ConstraintsSql Constraints
Sql Constraints
 
Cardinality and participation constraints
Cardinality and participation constraintsCardinality and participation constraints
Cardinality and participation constraints
 
Dbms relational data model and sql queries
Dbms relational data model and sql queries Dbms relational data model and sql queries
Dbms relational data model and sql queries
 
Relational data model
Relational data modelRelational data model
Relational data model
 
Introduction to the Relational Model and SQL
Introduction to the Relational Model and SQLIntroduction to the Relational Model and SQL
Introduction to the Relational Model and SQL
 
Database constraints
Database constraintsDatabase constraints
Database constraints
 
Intro to relational model
Intro to relational modelIntro to relational model
Intro to relational model
 
Relational model
Relational modelRelational model
Relational model
 
Referential integrity
Referential integrityReferential integrity
Referential integrity
 
Pokok bahasan #3a er modeling
Pokok bahasan #3a er modelingPokok bahasan #3a er modeling
Pokok bahasan #3a er modeling
 
2. relational model_150903
2. relational model_1509032. relational model_150903
2. relational model_150903
 
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization Techniques
 
Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1
 

Similar to ER diagram

Databases - Unit 2.pdf
Databases - Unit 2.pdfDatabases - Unit 2.pdf
Databases - Unit 2.pdfCynthiaAdzornu
 
DBMS-Keys , Attributes and Constraints.pptx
DBMS-Keys , Attributes and Constraints.pptxDBMS-Keys , Attributes and Constraints.pptx
DBMS-Keys , Attributes and Constraints.pptxsajinis5
 
ER Digramms by Harshal wagh
ER Digramms by Harshal waghER Digramms by Harshal wagh
ER Digramms by Harshal waghharshalkwagh999
 
ER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMSER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMSRubal Sagwal
 
5. relational structure
5. relational structure5. relational structure
5. relational structurekhoahuy82
 
Joins & constraints
Joins & constraintsJoins & constraints
Joins & constraintsVENNILAV6
 
18306_lec-2 (1).ppt
18306_lec-2 (1).ppt18306_lec-2 (1).ppt
18306_lec-2 (1).pptIshuIswarya3
 
Database Management Systems 4 - Normalization
Database Management Systems 4 - NormalizationDatabase Management Systems 4 - Normalization
Database Management Systems 4 - NormalizationNickkisha Farrell
 
Types of keys in database | SQL
Types of keys in database | SQLTypes of keys in database | SQL
Types of keys in database | SQLSumit Pandey
 
entityrelationshipmodel.pptx
entityrelationshipmodel.pptxentityrelationshipmodel.pptx
entityrelationshipmodel.pptxThangamaniR3
 
19IS305_U2_LP4_LM4-22-23.pdf
19IS305_U2_LP4_LM4-22-23.pdf19IS305_U2_LP4_LM4-22-23.pdf
19IS305_U2_LP4_LM4-22-23.pdfGOWTHAMR721887
 
Module 2 dbms.pptx
Module 2 dbms.pptxModule 2 dbms.pptx
Module 2 dbms.pptxVijishK
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity ConstraintsMegha yadav
 
Chapter-5 The Relational Data Model
Chapter-5 The Relational Data ModelChapter-5 The Relational Data Model
Chapter-5 The Relational Data ModelKunal Anand
 
DATA MODEL PRESENTATION UNIT I-BCA I.pptx
DATA MODEL PRESENTATION UNIT I-BCA I.pptxDATA MODEL PRESENTATION UNIT I-BCA I.pptx
DATA MODEL PRESENTATION UNIT I-BCA I.pptxJasmineMichael1
 

Similar to ER diagram (20)

Databases - Unit 2.pdf
Databases - Unit 2.pdfDatabases - Unit 2.pdf
Databases - Unit 2.pdf
 
DBMS-Keys , Attributes and Constraints.pptx
DBMS-Keys , Attributes and Constraints.pptxDBMS-Keys , Attributes and Constraints.pptx
DBMS-Keys , Attributes and Constraints.pptx
 
ER Digramms by Harshal wagh
ER Digramms by Harshal waghER Digramms by Harshal wagh
ER Digramms by Harshal wagh
 
ER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMSER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMS
 
5. relational structure
5. relational structure5. relational structure
5. relational structure
 
Data Models.pptx
Data Models.pptxData Models.pptx
Data Models.pptx
 
DATABASE DESIGN.pptx
DATABASE DESIGN.pptxDATABASE DESIGN.pptx
DATABASE DESIGN.pptx
 
Joins & constraints
Joins & constraintsJoins & constraints
Joins & constraints
 
18306_lec-2 (1).ppt
18306_lec-2 (1).ppt18306_lec-2 (1).ppt
18306_lec-2 (1).ppt
 
ERD(2).ppt
ERD(2).pptERD(2).ppt
ERD(2).ppt
 
Database Management Systems 4 - Normalization
Database Management Systems 4 - NormalizationDatabase Management Systems 4 - Normalization
Database Management Systems 4 - Normalization
 
Types of keys in database | SQL
Types of keys in database | SQLTypes of keys in database | SQL
Types of keys in database | SQL
 
entityrelationshipmodel.pptx
entityrelationshipmodel.pptxentityrelationshipmodel.pptx
entityrelationshipmodel.pptx
 
19IS305_U2_LP4_LM4-22-23.pdf
19IS305_U2_LP4_LM4-22-23.pdf19IS305_U2_LP4_LM4-22-23.pdf
19IS305_U2_LP4_LM4-22-23.pdf
 
Module 2 dbms.pptx
Module 2 dbms.pptxModule 2 dbms.pptx
Module 2 dbms.pptx
 
Dbms keysppt
Dbms keyspptDbms keysppt
Dbms keysppt
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
Chapter-5 The Relational Data Model
Chapter-5 The Relational Data ModelChapter-5 The Relational Data Model
Chapter-5 The Relational Data Model
 
DATA MODEL PRESENTATION UNIT I-BCA I.pptx
DATA MODEL PRESENTATION UNIT I-BCA I.pptxDATA MODEL PRESENTATION UNIT I-BCA I.pptx
DATA MODEL PRESENTATION UNIT I-BCA I.pptx
 
Create table
Create tableCreate table
Create table
 

Recently uploaded

Path loss model, OKUMURA Model, Hata Model
Path loss model, OKUMURA Model, Hata ModelPath loss model, OKUMURA Model, Hata Model
Path loss model, OKUMURA Model, Hata ModelDrAjayKumarYadav4
 
Working Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdfWorking Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdfSkNahidulIslamShrabo
 
Raashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashidFaiyazSheikh
 
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdfInvolute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdfJNTUA
 
What is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsWhat is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsVIEW
 
21P35A0312 Internship eccccccReport.docx
21P35A0312 Internship eccccccReport.docx21P35A0312 Internship eccccccReport.docx
21P35A0312 Internship eccccccReport.docxrahulmanepalli02
 
Databricks Generative AI Fundamentals .pdf
Databricks Generative AI Fundamentals  .pdfDatabricks Generative AI Fundamentals  .pdf
Databricks Generative AI Fundamentals .pdfVinayVadlagattu
 
Artificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfArtificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfKira Dess
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxkalpana413121
 
Basics of Relay for Engineering Students
Basics of Relay for Engineering StudentsBasics of Relay for Engineering Students
Basics of Relay for Engineering Studentskannan348865
 
Presentation on Slab, Beam, Column, and Foundation/Footing
Presentation on Slab,  Beam, Column, and Foundation/FootingPresentation on Slab,  Beam, Column, and Foundation/Footing
Presentation on Slab, Beam, Column, and Foundation/FootingEr. Suman Jyoti
 
Artificial Intelligence in due diligence
Artificial Intelligence in due diligenceArtificial Intelligence in due diligence
Artificial Intelligence in due diligencemahaffeycheryld
 
Adsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) pptAdsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) pptjigup7320
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...archanaece3
 
一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样
一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样
一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样A
 
Geometric constructions Engineering Drawing.pdf
Geometric constructions Engineering Drawing.pdfGeometric constructions Engineering Drawing.pdf
Geometric constructions Engineering Drawing.pdfJNTUA
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...IJECEIAES
 
handbook on reinforce concrete and detailing
handbook on reinforce concrete and detailinghandbook on reinforce concrete and detailing
handbook on reinforce concrete and detailingAshishSingh1301
 
Call for Papers - Journal of Electrical Systems (JES), E-ISSN: 1112-5209, ind...
Call for Papers - Journal of Electrical Systems (JES), E-ISSN: 1112-5209, ind...Call for Papers - Journal of Electrical Systems (JES), E-ISSN: 1112-5209, ind...
Call for Papers - Journal of Electrical Systems (JES), E-ISSN: 1112-5209, ind...Christo Ananth
 

Recently uploaded (20)

Path loss model, OKUMURA Model, Hata Model
Path loss model, OKUMURA Model, Hata ModelPath loss model, OKUMURA Model, Hata Model
Path loss model, OKUMURA Model, Hata Model
 
Working Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdfWorking Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdf
 
Raashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashid final report on Embedded Systems
Raashid final report on Embedded Systems
 
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdfInvolute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
 
What is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsWhat is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, Functions
 
21P35A0312 Internship eccccccReport.docx
21P35A0312 Internship eccccccReport.docx21P35A0312 Internship eccccccReport.docx
21P35A0312 Internship eccccccReport.docx
 
Databricks Generative AI Fundamentals .pdf
Databricks Generative AI Fundamentals  .pdfDatabricks Generative AI Fundamentals  .pdf
Databricks Generative AI Fundamentals .pdf
 
Signal Processing and Linear System Analysis
Signal Processing and Linear System AnalysisSignal Processing and Linear System Analysis
Signal Processing and Linear System Analysis
 
Artificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfArtificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdf
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptx
 
Basics of Relay for Engineering Students
Basics of Relay for Engineering StudentsBasics of Relay for Engineering Students
Basics of Relay for Engineering Students
 
Presentation on Slab, Beam, Column, and Foundation/Footing
Presentation on Slab,  Beam, Column, and Foundation/FootingPresentation on Slab,  Beam, Column, and Foundation/Footing
Presentation on Slab, Beam, Column, and Foundation/Footing
 
Artificial Intelligence in due diligence
Artificial Intelligence in due diligenceArtificial Intelligence in due diligence
Artificial Intelligence in due diligence
 
Adsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) pptAdsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) ppt
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...
 
一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样
一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样
一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样
 
Geometric constructions Engineering Drawing.pdf
Geometric constructions Engineering Drawing.pdfGeometric constructions Engineering Drawing.pdf
Geometric constructions Engineering Drawing.pdf
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...
 
handbook on reinforce concrete and detailing
handbook on reinforce concrete and detailinghandbook on reinforce concrete and detailing
handbook on reinforce concrete and detailing
 
Call for Papers - Journal of Electrical Systems (JES), E-ISSN: 1112-5209, ind...
Call for Papers - Journal of Electrical Systems (JES), E-ISSN: 1112-5209, ind...Call for Papers - Journal of Electrical Systems (JES), E-ISSN: 1112-5209, ind...
Call for Papers - Journal of Electrical Systems (JES), E-ISSN: 1112-5209, ind...
 

ER diagram

  • 1. NAME : MITALI MANIYAR EN.NO.:150410107048 CLASS : SY CE-1 DEPT. : COMPUTER Constraints, Keys, Design issues , E-R diagrams
  • 2. KEYS A key is an attribute or set of attributes that uniquely identifies a tuple in a relation/table. Keys are used to access or sequence stored data and to create relationship between different tables. Types of Keys are: 1.Primary key 2.Foreign key 3.Super key 4.Candidate key 5.Unique key
  • 3. • Primary Key – A primary is a column or set of columns in a table that uniquely identifies tuples (rows) in that table. • Super Key – A super key is a set of one of more columns (attributes) to uniquely identify rows in a table. • Candidate Key – A super key with no redundant attribute is known as candidate key. With the help of primary key, candidate key can use to identify all other tuples in table. • Foreign Key – Foreign keys are the columns of a table that points to the primary key of another table. They act as a cross-reference between tables. • Unique Key – Unique key is a special case of primary key. It has a condition that its value can be null while in primary key can’t have null value as input.
  • 4.
  • 5. CONSTRAINT • Constraints enforce limits to the data or type of data that can be inserted/updated/deleted from a table. The whole purpose of constraints is to maintain the data integrity during an update/delete/insert into a table. In this tutorial we will learn several types of constraints that can be created in Relational DBMS. • Types of constraints 1.NOT NULL 2.UNIQUE 3.DEFAULT 4.CHECK 5.Key Constraints – PRIMARY KEY, FOREIGN KEY
  • 6. Not Null • NOT NULL constraint makes sure that a column does not hold NULL value. When we don’t provide value for a particular column while inserting a record into a table, it takes NULL value by default. By specifying NULL constraint, we can be sure that a particular column(s) cannot have NULL values. Unique • UNIQUE Constraint enforces a column or set of columns to have unique values. If a column has a unique constraint, it means that particular column cannot have duplicate values in a table. CREATE TABLE STUDENT( ROLL_NO NUMBER NOT NULL, STU_NAME VARCHAR (35) NOT NULL, STU_AGE NUMBER NOT NULL, STU_ADDRESS VARCHAR (235), PRIMARY KEY (ROLL_NO) ); CREATE TABLE STUDENT( ROLL_NO NUMBER NOT NULL, STU_NAME VARCHAR (35) NOT NULL UNIQUE, STU_AGE NUMBER NOT NULL, STU_ADDRESS VARCHAR (35) UNIQUE, PRIMARY KEY (ROLL_NO) );
  • 7. Default • The DEFAULT constraint provides a default value to a column when there is no value provided while inserting a record into a table. Check • This constraint is used for specifying range of values for a particular column of a table. When this constraint is being set on a column, it ensures that the specified column must have the value falling in the specified range. CREATE TABLE STUDENT( ROLL_NO NUMBER NOT NULL, STU_NAME VARCHAR (35) NOT NULL, STU_AGE NUMBER NOT NULL, EXAM_FEE NUMBER DEFAULT 10000, STU_ADDRESS VARCHAR (35) , PRIMARY KEY (ROLL_NO) ); CREATE TABLE STUDENT( ROLL_NO NUMBER NOT NULL CHECK(ROLL_NO >1000), STU_NAME VARCHAR (35) NOT NULL, STU_AGE NUMBER NOT NULL, EXAM_FEE NUMBER DEFAULT 10000, STU_ADDRESS VARCHAR (35) , PRIMARY KEY (ROLL_NO) );
  • 8. KEY CONSTRAINTS Primary Key • Primary key uniquely identifies each record in a table. It must have unique values and cannot contain nulls. In the below example the ROLL_NO field is marked as primary key, that means the ROLL_NO field cannot have duplicate and null values. Foreign key • Foreign keys are the columns of a table that points to the primary key of another table. They act as a cross-reference between tables. CREATE TABLE STUDENT( ROLL_NO NUMBER NOT NULL, STU_NAME VARCHAR (35) NOT NULL UNIQUE, STU_AGE NUMBER NOT NULL, STU_ADDRESS VARCHAR (35) UNIQUE, PRIMARY KEY (ROLL_NO) );
  • 9. ER DIAGRAMS • An Entity Relationship Diagram (ERD) is a visual representation of different data using conventions that describe how these data are related to each other. For example, the elements writer, novel, and consumer may be described using ER diagrams this way. • In the diagram, the elements inside rectangles are called entities while the items inside diamonds denote the relationships between entities.
  • 10. ER DIAGRAM SYMBOL AND NOTATION • There are three basic elements in an ER Diagram: entity, attribute, relationship. There are more elements which are based on the main elements. They are weak entity, multivalued attribute, derived attribute, weak relationship and recursive relationship.
  • 11. Entity • An entity can be a person, place, event, or object that is relevant to a given system. For example, a school system may include students, teachers, major courses, subjects, fees, and other items. Entities are represented in ER diagrams by a rectangle and named using singular nouns. • weak entity is an entity that depends on the existence of another entity. In more technical terms it can defined as an entity that cannot be identified by its own attributes. It uses a foreign key combined with its attributed to form the primary key. Attributes • An attribute is a property, trait, or characteristic of an entity, relationship, or another attribute. For example, the attribute Inventory Item Name is an attribute of the entity Inventory Item. An entity can have as many attributes as necessary. Meanwhile, attributes can also have their own specific attributes. For example, the attribute “customer address” can have the attributes number, street, city, and state. • There are composite attribute, multivalued attribute and derived attribute .
  • 12. Relationship • A relationship describes how entities interact. For example, the entity “carpenter” may be related to the entity “table” by the relationship “builds” or “makes”. Relationships are represented by diamond shapes and are labelled using verbs.
  • 13. HOW TO DRAW E-R DIAGRAMS ? • Identify all the relevant entities in a given system and determine the relationships among these entities. • An entity should appear only once in a particular diagram. • Provide a precise and appropriate name for each entity, attribute, and relationship in the diagram. Terms that are simple and familiar always beats vague, technical-sounding words. In naming entities, remember to use singular nouns. However, adjectives may be used to distinguish entities belonging to the same class (part-time employee and full time employee, for example). Meanwhile attribute names must be meaningful, unique, system-independent, and easily understandable. • Remove vague, redundant or unnecessary relationships between entities. • Never connect a relationship to another relationship.
  • 14. DESIGN ISSUES • It is not always clear whether an object is best expressed by an entity set or a relationship set. • Two problems arise as a result of the replication: (1) the data are stored multiple times, wasting storage space, and (2) updates potentially leave the data in an inconsistent state, where the values differ in two relationships for attributes that are supposed to have the same value. • Relationships in databases are often binary. Some relationships that appear to be nonbinary could actually be better represented by several binary relationships.