SlideShare a Scribd company logo
1 of 5
Explain the concept of Foreign Key. How a foreign key differs from a Primary Key? Can the Foreign Key accept
nulls?
Answer
Foreign Key:
A foreign key is a column in a table where that column is primary key of another table, which means that any
data in a foreign key column must have corresponding data in the other table where that column is the primary
key. Whereas primary key is a column or set of columns that uniquely identifies the rest of the data in any given
row.
For e.g consider a Table:
Students ID
number
Student
name
Subject enrolled In
Year of
course
1245 Sanjay Mathematics 3
1246 Vijay Science 4
1247 Jameel Political science 3
1248 Nitesh Arts 3
In the above table “Student ID number” is the primary key as this uniquely identifies that row. This means no
two rows can have the same “Student ID number” and is two students have the same name then “Student ID
number” ensures that those two students are not same.
Therefore if this “Student ID number” is used as a primary key for some other table then this ID is the foreign
key. No component of the primary key can be null whereas in the case of foreign key there is no integrity rule
saying that no component of the foreign key can be null. Therefore foreign key accepts null.
With a necessary example explain (i) Basic Constructs of E-R Modeling (ii) E-R Notations.
Answer
Entity name
Entity Relationship name
One Many
vlanages
Relationship
Attribute name
Mandatory existence Optional existence
ER NOTATION
Department
DepID
Project
ProjectID
Constructs of E-R Modeling: ER modeling views the real worlds as a constructs of entities and association
between entities.
Entities: Entities are the principal data object about which information is to be collected. It is classified as
independent or dependent. An independent entity is one that does not rely on another for identification
whereas dependent is one that relies on another for identification. Special entity types are associative, and
subtype entities.
Relationship: a relationship represents as association between two or more entities. Relationships are classified
in terms of degree, connectivity, cardinality and existence.
Attributes: Attributes describes the entity of which they are associated. Attributes can be classified as
identifiers or descriptors. Identifiers, or keys, uniquely identify an instance of an entity. A descriptor describes a
non-unique characteristic of an entity instance.
Degree of relationship: It is the number of entities associated with the relationship
Connectivity and cardinality: It describes the mapping of associated entity instance in a relationship. The value
of connectivity are one-to-one (1: 1), one-to-many (1 : N), Many-to-Many (M : N).
Direction: Direction of a relationship indicates the originating entity of a binary relationship the entity from
which a relationship originates is the parent entity and entity where relationship terminates is the child entity.
Existence: Existence denotes whether the existence of an entity instance is dependent upon the existence of
another, related, entity instance.
ER Notations: Basic ER notations are as:
1) Entities are represented by labeled rectangles.
2) Relationships are represented by a solid line connecting two entities.
3) Attributes when included are listed inside the entity rectangle. Attributes which are identifiers are
underlined
4) Cardinality of many is represented by a line ending in a crow’s foot. If the crow’s foot is omitted, the
cardinality is one.
5) Existence is represented by placing a circle or a perpendicular bar on the line.
Explain the first 3 Normal Forms taking the help of an un-normalized relation and reducing it to 3 NF.
Answer
Normalization is the process of efficiently organizing data in a database.
First Normal Form (1NF): A relation which contains a repeating group is called an un-normalized relation.
Therefore a relation is said to be in first normal form if it does not contain repeating groups.
Second Normal Form (2NF): A relation is said to be in 2NF if it is in 1NF and no non-key attribute is functionally
dependent on only a portion of the primary key. For example consider a table Software.
Software
packid packname tagnumber cost cmpid
MST microsoft 11382 500 M223
DBS Database 11256 400 S456
FP1 IBM 11695 900 D765
FP1 IBM 11584 700 S098
As we can see that in the column packid FP1 occurs several times. This causes several problems like wastage of
memory and update, inconsistent data addition and deletions problems. Therefore a relation is said to be in
2NF if it is in 1NF and contains no partial dependencies, so software table is currently is not in 2NF, Method to
convert it into 2NF is as follows.
For each subset of the set of attributes , which make up the primary key start a relation with this subset as its
primary key so for software relation , now place the other attributes in such a way that we obtain minimal
relation for which these subsets of attributes are primary key, so we obtain
(packid, packname)
(tagnumber,cmpid)
(packid,tagnumber,cost)
So each of above relation can now be given a name which is descriptive of the meaning of the relation e.g.
PACK, COMP, SOFT.
Third Normal Form (3NF): A relation is said to be in 3NF if it is in 2NF and if the only determinants it has are
candidate keys. Where an attribute which determines another attribute is called determinant.
Explain the concept of Data Mining? How it is related with data warehouse.
Answer
Data mining: Data mining is basically used to discover new rules and patterns from the supplied data. It is also
said that it addresses inductive knowledge. Following are the five knowledge discovered during data mining
Association rule: these rules correlate the presence of a set of items with another range of values for another
set of variables.
Classification hierarchies: the goal is to work from an existing set of events or transactions to create a hierarchy
of classes.
Sequential patterns: A sequence of actions or events is sought.
Patterns with time series: Similarities can be detected within position of time series of data, which is a sequence
of data taken at regular interval such as daily sales or daily closing stock prices.
Clustering: A given population of events can be partitioned into set of similar elements.
As data mining concept can be applied to large variety of decision making contexts in business, some particular
areas are Marketing, Finance, Manufacturing, Health care
Further Data mining is related with data warehouse as follows:
As goal of data warehouse is to support decision making with data. Data mining can be used in conjunction with
a data warehouse to help with certain types of decisions. Data mining can be applied to operational databases
with individual transactions. To make data mining more efficient, the data warehouse should have an
aggregated or summarized collection of data. Data mining helps in extracting meaningful new patterns that
cannot be found by merely querying or processing data in the data warehouse. Data mining application should
therefore be strongly considered early, during the design of the data warehouse. Also data mining tools should
be designed to facilitate their use in conjunction with data warehouse. In fact for very large databases running
into terabytes of data, successful use of data mining applications will depend first on the construction of a data
warehouse.
Therefore data warehouse provides access to data for complex analysis, knowledge discovery and decision
making and they support high-performance on an organization’s data and information whereas data mining is
used to discover new rules and patterns from the supplied data.
Write the SQL queries using Data Manipulation Language (DML) statements.
(a) Insert values into student table with field names using insert command
(b) Display the table student using select command
(c) Update student address in student table using update command.
(d) Delete a row from student table.
Answer
Creating a Table:
CREATE TABLE STUDENT
(
Student INT,
First name VARCHAR (20),
Last name VARCHAR (20),
Gender ENUM (‘M’,’F’),
Address VARCHAR (100)
)
(a) Insert values into student table with field names using insert command
INSERT INTO STUDENT(StudentID,Firstname,Lastname,Gender,Address)VALUES(234,nikhil,singh,M,H-12 Delhi);
(b) Display the table student using select command
SELECT StudentID,Firstname,Lastname,Gender,Address FROM STUDENT;
(c) Update student address in student table using update command
UPDATE STUDENT address = H-29 new Delhi WHERE ITEM = ‘H-12 Delhi’;
(d) Delete a row from student table
DELETE FROM STUDENT WHERE studentID=’234’ AND first name = Nikhil AND last name = Singh ;
Create the payroll database considering table employee.
(a) Do simple queries on the above database.
i. List all information of the above both tables.
ii. List the empno, ename, jobtitle,and hiredate of employee from the employee table.
(b) List the name, salary of the employees who are clerks.
(c) List the name,job,salary of every employee joined on certain date. (say ‘december 17,1980’)
(d) List name and annual salary of all the employees.
(e) List the employees who have salary between certain range (say between Rs. 1000 & 2000)
Answer
CREATE TABLE employee
(
emp_no INT
ename VARCHAR(20)
job title VARCHAR(16)
salary INT
hiredate DATE
);
(a) (1) List all information of the above both tables.
SELECT * FROM employee;
(2) List the empno, ename, jobtitle,and hiredate of employee from the employee table
SELECT empno, ename, jobtitle, hiredate FROM employee;
(b) List the name, salary of the employees who are clerks
SELECT ename, salary FROM employee WHERE job title = ‘clerks’;
(c) List the name,job,salary of every employee joined on certain date. (say ‘december 17,1980’)
SELECT ename, job title, salary FROM employee WHERE hiredate = ‘december 17,1980’;
(d) List name and annual salary of all the employees.
SELECT ename, SUM(salary) FROM employee GROUP BY ename;
(e) List the employees who have salary between certain range (say between Rs. 1000 & 2000)
SELECT ename FROM employee WHERE salary BETWEEN 1000 AND 2000;

More Related Content

What's hot

5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS
koolkampus
 
Chapter3 the relational data model and the relation database constraints part2
Chapter3 the relational data model and the relation database constraints part2Chapter3 the relational data model and the relation database constraints part2
Chapter3 the relational data model and the relation database constraints part2
eidah20
 

What's hot (20)

The Relational Model
The Relational ModelThe Relational Model
The Relational Model
 
Deductive Database
Deductive DatabaseDeductive Database
Deductive Database
 
Relational model
Relational modelRelational model
Relational model
 
Deductive databases
Deductive databasesDeductive databases
Deductive databases
 
Relational model
Relational modelRelational model
Relational model
 
Dbms
DbmsDbms
Dbms
 
Sec 2 1st term rev.
Sec 2  1st term rev.Sec 2  1st term rev.
Sec 2 1st term rev.
 
Denormalization
DenormalizationDenormalization
Denormalization
 
Fundamentals of database system - Relational data model and relational datab...
Fundamentals of database system  - Relational data model and relational datab...Fundamentals of database system  - Relational data model and relational datab...
Fundamentals of database system - Relational data model and relational datab...
 
Database Assignment
Database AssignmentDatabase Assignment
Database Assignment
 
5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS
 
Chapter3 the relational data model and the relation database constraints part2
Chapter3 the relational data model and the relation database constraints part2Chapter3 the relational data model and the relation database constraints part2
Chapter3 the relational data model and the relation database constraints part2
 
Computer sec2-1st term
Computer sec2-1st termComputer sec2-1st term
Computer sec2-1st term
 
CIS 336 Wonderful Education--cis336.com
CIS 336 Wonderful Education--cis336.comCIS 336 Wonderful Education--cis336.com
CIS 336 Wonderful Education--cis336.com
 
Relational database intro for marketers
Relational database intro for marketersRelational database intro for marketers
Relational database intro for marketers
 
Efficiency of TreeMatch Algorithm in XML Tree Pattern Matching
Efficiency of TreeMatch Algorithm in XML Tree Pattern  MatchingEfficiency of TreeMatch Algorithm in XML Tree Pattern  Matching
Efficiency of TreeMatch Algorithm in XML Tree Pattern Matching
 
The relational data model part[1]
The relational data model part[1]The relational data model part[1]
The relational data model part[1]
 
Presentation
PresentationPresentation
Presentation
 
Database : Relational Data Model
Database : Relational Data ModelDatabase : Relational Data Model
Database : Relational Data Model
 
Islamic University Previous Year Question Solution 2019 (ADBMS)
Islamic University Previous Year Question Solution 2019 (ADBMS)Islamic University Previous Year Question Solution 2019 (ADBMS)
Islamic University Previous Year Question Solution 2019 (ADBMS)
 

Similar to Bc0041

Introduction to Data Structure
Introduction to Data StructureIntroduction to Data Structure
Introduction to Data Structure
Jazz Jinia Bhowmik
 

Similar to Bc0041 (20)

Chapter 1
Chapter 1Chapter 1
Chapter 1
 
COMPUTERS Database
COMPUTERS Database COMPUTERS Database
COMPUTERS Database
 
2. Introduction to Data Structure.pdf
2. Introduction to Data Structure.pdf2. Introduction to Data Structure.pdf
2. Introduction to Data Structure.pdf
 
Dsa unit 1
Dsa unit 1Dsa unit 1
Dsa unit 1
 
DBMS (1).pptx
DBMS (1).pptxDBMS (1).pptx
DBMS (1).pptx
 
Bca examination 2017 dbms
Bca examination 2017 dbmsBca examination 2017 dbms
Bca examination 2017 dbms
 
NMEC RD_UNIT 1.ppt
NMEC RD_UNIT 1.pptNMEC RD_UNIT 1.ppt
NMEC RD_UNIT 1.ppt
 
DATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTESDATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTES
 
WEKA:Data Mining Input Concepts Instances And Attributes
WEKA:Data Mining Input Concepts Instances And AttributesWEKA:Data Mining Input Concepts Instances And Attributes
WEKA:Data Mining Input Concepts Instances And Attributes
 
WEKA: Data Mining Input Concepts Instances And Attributes
WEKA: Data Mining Input Concepts Instances And AttributesWEKA: Data Mining Input Concepts Instances And Attributes
WEKA: Data Mining Input Concepts Instances And Attributes
 
Data_Structure_and_Algorithms_Using_C++ _ Nho Vĩnh Share.pdf
Data_Structure_and_Algorithms_Using_C++ _ Nho Vĩnh Share.pdfData_Structure_and_Algorithms_Using_C++ _ Nho Vĩnh Share.pdf
Data_Structure_and_Algorithms_Using_C++ _ Nho Vĩnh Share.pdf
 
104333 sri vidhya eng notes
104333 sri vidhya eng notes104333 sri vidhya eng notes
104333 sri vidhya eng notes
 
Introduction to Data Structure
Introduction to Data StructureIntroduction to Data Structure
Introduction to Data Structure
 
1- Introduction.pptx.pdf
1- Introduction.pptx.pdf1- Introduction.pptx.pdf
1- Introduction.pptx.pdf
 
D B M S Animate
D B M S AnimateD B M S Animate
D B M S Animate
 
Excel analysis assignment this is an independent assignment me
Excel analysis assignment this is an independent assignment meExcel analysis assignment this is an independent assignment me
Excel analysis assignment this is an independent assignment me
 
UNIT II DBMS.pptx
UNIT II DBMS.pptxUNIT II DBMS.pptx
UNIT II DBMS.pptx
 
Application for Logical Expression Processing
Application for Logical Expression Processing Application for Logical Expression Processing
Application for Logical Expression Processing
 
Data resource management
Data resource managementData resource management
Data resource management
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
 

Recently uploaded

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 

Recently uploaded (20)

Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 

Bc0041

  • 1. Explain the concept of Foreign Key. How a foreign key differs from a Primary Key? Can the Foreign Key accept nulls? Answer Foreign Key: A foreign key is a column in a table where that column is primary key of another table, which means that any data in a foreign key column must have corresponding data in the other table where that column is the primary key. Whereas primary key is a column or set of columns that uniquely identifies the rest of the data in any given row. For e.g consider a Table: Students ID number Student name Subject enrolled In Year of course 1245 Sanjay Mathematics 3 1246 Vijay Science 4 1247 Jameel Political science 3 1248 Nitesh Arts 3 In the above table “Student ID number” is the primary key as this uniquely identifies that row. This means no two rows can have the same “Student ID number” and is two students have the same name then “Student ID number” ensures that those two students are not same. Therefore if this “Student ID number” is used as a primary key for some other table then this ID is the foreign key. No component of the primary key can be null whereas in the case of foreign key there is no integrity rule saying that no component of the foreign key can be null. Therefore foreign key accepts null. With a necessary example explain (i) Basic Constructs of E-R Modeling (ii) E-R Notations. Answer Entity name Entity Relationship name One Many vlanages Relationship Attribute name Mandatory existence Optional existence ER NOTATION Department DepID Project ProjectID
  • 2. Constructs of E-R Modeling: ER modeling views the real worlds as a constructs of entities and association between entities. Entities: Entities are the principal data object about which information is to be collected. It is classified as independent or dependent. An independent entity is one that does not rely on another for identification whereas dependent is one that relies on another for identification. Special entity types are associative, and subtype entities. Relationship: a relationship represents as association between two or more entities. Relationships are classified in terms of degree, connectivity, cardinality and existence. Attributes: Attributes describes the entity of which they are associated. Attributes can be classified as identifiers or descriptors. Identifiers, or keys, uniquely identify an instance of an entity. A descriptor describes a non-unique characteristic of an entity instance. Degree of relationship: It is the number of entities associated with the relationship Connectivity and cardinality: It describes the mapping of associated entity instance in a relationship. The value of connectivity are one-to-one (1: 1), one-to-many (1 : N), Many-to-Many (M : N). Direction: Direction of a relationship indicates the originating entity of a binary relationship the entity from which a relationship originates is the parent entity and entity where relationship terminates is the child entity. Existence: Existence denotes whether the existence of an entity instance is dependent upon the existence of another, related, entity instance. ER Notations: Basic ER notations are as: 1) Entities are represented by labeled rectangles. 2) Relationships are represented by a solid line connecting two entities. 3) Attributes when included are listed inside the entity rectangle. Attributes which are identifiers are underlined 4) Cardinality of many is represented by a line ending in a crow’s foot. If the crow’s foot is omitted, the cardinality is one. 5) Existence is represented by placing a circle or a perpendicular bar on the line. Explain the first 3 Normal Forms taking the help of an un-normalized relation and reducing it to 3 NF. Answer Normalization is the process of efficiently organizing data in a database. First Normal Form (1NF): A relation which contains a repeating group is called an un-normalized relation. Therefore a relation is said to be in first normal form if it does not contain repeating groups. Second Normal Form (2NF): A relation is said to be in 2NF if it is in 1NF and no non-key attribute is functionally dependent on only a portion of the primary key. For example consider a table Software. Software packid packname tagnumber cost cmpid MST microsoft 11382 500 M223 DBS Database 11256 400 S456 FP1 IBM 11695 900 D765 FP1 IBM 11584 700 S098 As we can see that in the column packid FP1 occurs several times. This causes several problems like wastage of memory and update, inconsistent data addition and deletions problems. Therefore a relation is said to be in 2NF if it is in 1NF and contains no partial dependencies, so software table is currently is not in 2NF, Method to convert it into 2NF is as follows.
  • 3. For each subset of the set of attributes , which make up the primary key start a relation with this subset as its primary key so for software relation , now place the other attributes in such a way that we obtain minimal relation for which these subsets of attributes are primary key, so we obtain (packid, packname) (tagnumber,cmpid) (packid,tagnumber,cost) So each of above relation can now be given a name which is descriptive of the meaning of the relation e.g. PACK, COMP, SOFT. Third Normal Form (3NF): A relation is said to be in 3NF if it is in 2NF and if the only determinants it has are candidate keys. Where an attribute which determines another attribute is called determinant. Explain the concept of Data Mining? How it is related with data warehouse. Answer Data mining: Data mining is basically used to discover new rules and patterns from the supplied data. It is also said that it addresses inductive knowledge. Following are the five knowledge discovered during data mining Association rule: these rules correlate the presence of a set of items with another range of values for another set of variables. Classification hierarchies: the goal is to work from an existing set of events or transactions to create a hierarchy of classes. Sequential patterns: A sequence of actions or events is sought. Patterns with time series: Similarities can be detected within position of time series of data, which is a sequence of data taken at regular interval such as daily sales or daily closing stock prices. Clustering: A given population of events can be partitioned into set of similar elements. As data mining concept can be applied to large variety of decision making contexts in business, some particular areas are Marketing, Finance, Manufacturing, Health care Further Data mining is related with data warehouse as follows: As goal of data warehouse is to support decision making with data. Data mining can be used in conjunction with a data warehouse to help with certain types of decisions. Data mining can be applied to operational databases with individual transactions. To make data mining more efficient, the data warehouse should have an aggregated or summarized collection of data. Data mining helps in extracting meaningful new patterns that cannot be found by merely querying or processing data in the data warehouse. Data mining application should therefore be strongly considered early, during the design of the data warehouse. Also data mining tools should be designed to facilitate their use in conjunction with data warehouse. In fact for very large databases running into terabytes of data, successful use of data mining applications will depend first on the construction of a data warehouse. Therefore data warehouse provides access to data for complex analysis, knowledge discovery and decision making and they support high-performance on an organization’s data and information whereas data mining is used to discover new rules and patterns from the supplied data.
  • 4. Write the SQL queries using Data Manipulation Language (DML) statements. (a) Insert values into student table with field names using insert command (b) Display the table student using select command (c) Update student address in student table using update command. (d) Delete a row from student table. Answer Creating a Table: CREATE TABLE STUDENT ( Student INT, First name VARCHAR (20), Last name VARCHAR (20), Gender ENUM (‘M’,’F’), Address VARCHAR (100) ) (a) Insert values into student table with field names using insert command INSERT INTO STUDENT(StudentID,Firstname,Lastname,Gender,Address)VALUES(234,nikhil,singh,M,H-12 Delhi); (b) Display the table student using select command SELECT StudentID,Firstname,Lastname,Gender,Address FROM STUDENT; (c) Update student address in student table using update command UPDATE STUDENT address = H-29 new Delhi WHERE ITEM = ‘H-12 Delhi’; (d) Delete a row from student table DELETE FROM STUDENT WHERE studentID=’234’ AND first name = Nikhil AND last name = Singh ;
  • 5. Create the payroll database considering table employee. (a) Do simple queries on the above database. i. List all information of the above both tables. ii. List the empno, ename, jobtitle,and hiredate of employee from the employee table. (b) List the name, salary of the employees who are clerks. (c) List the name,job,salary of every employee joined on certain date. (say ‘december 17,1980’) (d) List name and annual salary of all the employees. (e) List the employees who have salary between certain range (say between Rs. 1000 & 2000) Answer CREATE TABLE employee ( emp_no INT ename VARCHAR(20) job title VARCHAR(16) salary INT hiredate DATE ); (a) (1) List all information of the above both tables. SELECT * FROM employee; (2) List the empno, ename, jobtitle,and hiredate of employee from the employee table SELECT empno, ename, jobtitle, hiredate FROM employee; (b) List the name, salary of the employees who are clerks SELECT ename, salary FROM employee WHERE job title = ‘clerks’; (c) List the name,job,salary of every employee joined on certain date. (say ‘december 17,1980’) SELECT ename, job title, salary FROM employee WHERE hiredate = ‘december 17,1980’; (d) List name and annual salary of all the employees. SELECT ename, SUM(salary) FROM employee GROUP BY ename; (e) List the employees who have salary between certain range (say between Rs. 1000 & 2000) SELECT ename FROM employee WHERE salary BETWEEN 1000 AND 2000;