SlideShare a Scribd company logo
1 of 8
1
Introduction to the Relational Model
Question 1 : Define - Super Keys,Candidate Keys,Primary Keys with example.
Answer :
Super Keys : A super key is a combination of columns that uniquely identifies
any row within a relational database management system (RDBMS) table.A
candidate key is a closely related concept where the super key is reduced to the
minimum number of columns required to uniquely identify each row.
Candidate Keys : A candidate key is a column or set of columns in a table that
can uniquely identify any database record without referring to any other
data.Each table may have one or more candidate keys but one candidate key is
unique and it is called the primary key.
Primary Key : A primary key,also called a primary keyword is a key in a
relational database that is unique for each record.It is a unique identifier such as
a driver license number,telephone number (including area code) or vehicle
identification number (VIN),A relational Database must always have one and
only primary key.
Lets take an example to understand super keys,candidate keys and primary key.
Emp_SSN Emp_Number Emp_Name
123456789 226 Jayed
999999321 227 Lipi
888997212 228 Asik
777778888 229 Helal
Super Keys :
 {Emp_SSN}
 {Emp_Number}
 {Emp_SSN,Emp_Number}
 {Emp_SSN,Emp_Number,Emp_Name}
 {Emp_Number,Emp_Name}
All of this above sets are able to uniquely identified.
Candidate key: As stated above that they are the minimal super keys with no
redundant attributes.
2
 {Emp_SSN}
 {Emp_Number}
Only these two sets are candidate keys as another sets are having redundant
attributes these are not necessary for unique identification.
Primary Key : Primary key is being selected from the sets of candidate keys by
database designer.So either {Emp_SSN} or {Emp_Number} can be the primary
key.
Question 2 : Write down any five symbols with examples of relational algebra.
Answer :
Symbol (Name) Example of Use
σ
(Selection)
σ salary > = 85000 (instructor)
Return rows of the input relation that satisfy the
predicate.
Π
(Projection)
Π ID, salary (instructor)
Output specified attributes from all rows of the
input relation. Remove duplicate tuples from the
output
x
(Cartesian Product)
instructor x department
Output pairs of rows from the two input relations
that have the same value on all attributes that have
the same name
∪
(Union)
Π name (instructor) ∪ Π name (student)
Output the union of tuples from the two input
relations.
⋈
(Natural Join)
instructor ⋈ department
Output pairs of rows from the two input relations
that have the same value on all attributes that have
the same name.
3
Solution Of Practice Exercises
Question 2.1 : Consider the relational database of Figure 2.14 What are the
appropriate primary keys?
Answer : The answer is shown in Figure 2.1, with primary keys underlined.
Question2.2 : Consider the foreign key constraint from the dept_name attribute
of instructor to the department relation.Give examples of inserts and deletes to
these relations,which can cause a violation of the foreign key constraint.
Answer : Inserting a tuple :
(10111, Ostrom, Economics, 110,000)
Into the instructor table,where the department table does nothave the department
Economics, would violate the foreign key constraint.
Deleting the tuple :
(Biology, Watson, 90000)
from the department table, where at least one student or instructor tuple has dept
name as biology, would violate the foreign key constraint.
employee (person_name, street, city)
works (person_name, company_name, salary)
company (company_name, city)
Figure 2.1 : Relational database for Practice Exercise 2.1.
Question 2.3 : Consider the time_slot relation. Given that a particular time slot
can meet more than once in a week, explain why day and start_time are part of
the primary key of this relation, while end_time is not.
Answer : The attributes day and start_time are part of the primary key since a
particular class will most likely meet on several different days, and may even
meet more than once in a day. However, end_time is not part of the primary key
since a particular class that starts at a particular time on a particular day cannot
end at more than one time.
Question2.4 :In the instance of instructor shown in Figure??.. no two instructors
have the same name. From this, can we conclude that name can be used as a
superkey (or primary key) of instructor?
4
Answer : No. For this possible instance of the instructor table the names are
unique, but in general this may not be always the case (unless the university has
a rule that two instructors cannot have the same name, which is a rather unlikey
scenario).
Question2.5 : What is the result of first performing the cross productofstudent
and advisor, and then performing a selection operation on the result with the
predicate s_id = ID? (Using the symbolic notation ofrelational algebra, this query
can be written as σs_id = ID(student × advisor).)
Answer : The result attributes include all attribute values of student followed by
all attributes of advisor. The tuples in the result are as follows. For each student
who has an advisor, the result has a row containing that students
attributes,followed by an s_id attribute identical to the students ID attribute,
followed by the i_id attribute containing the ID of the students advisor.
Students who do not have an advisor will not appear in the result. A student who
has more than one advisor will appear a corresponding number of times in the
result.
Question 2.6 : Consider the following expressions, which use the result of a
relational algebra operation as the input to another operation.For each expression,
explain in words what the expression does.
a. σyear ≥ 2009(takes) |×| student
b. σyear ≥ 2009(takes |×| student)
c. ΠID,name,course_id(student |×| takes)
Answer :
a. Foreach student who takes at least one course in 2009, display the students
information along with the information about what courses the student took.
The attributes in the result are:
ID, name, dept_name, tot_cred, course_id, section_id, semester, year, grade
b. Same as (a); selection can be done before the join operation.
c. Provide a list of consisting of
ID, name, course_id
of all students who took any coursein the university.
Question2.7 :Consider the relational database ofFigure 2.14 Give an expression
in the relational algebra to express each of the following queries :
5
a. Find the names of all employees who live in city “Miami”.
b. Find the names of all employees whose salary is greater than $100,000.
c. Find the names of all employees who live in “Miami” and whose salary is
greater than $100,000.
Answer :
a. Πname (σcity = “Miami” (employee))
b. Πname (σsalary >100000 (employee))
c. Πname (σcity = “Miami” ∧ salary>100000 (employee))
Question 2.8 : Consider the bank database of Figure 2.15 Give an expression in
the relational algebra for each of the following queries.
a. Find the names of all branches located in “Chicago”.
b. Find the names of all borrowers who have a loan in branch “Downtown”.
Answer:
a. Πbranch_name (σbranch_city = “Chicago” (branch))
b. Πcustomer_name (σbranch_name = “Downtown” (borrower |× loan))
6
Solution Of Exercises
Question 2.9 : Consider the bank database of Figure 2.15.
a. What are the appropriate primary keys?
b. Given your choice of primary keys,identify appropriate foreign keys.
Answer :
a. employee (person_name, street, city)
works (person_name, company_name, salary)
company (company_name, city)
Figure 2.14 : Relational database for Exercises 2.1, 2.7, and 2.12.
branch(branch_name, branch_city, assets)
customer (customer_name, customer_street, customer_city)
loan (loan_number, branch_name, amount)
borrower (customer_name, loan_number)
account (account_number, branch_name, balance)
depositor (customer_name, account_number)
Figure 2.15 : Banking database for Exercises 2.8, 2.9, and 2.13.
b. 1. The primary keys of the various schema are underlined. Although in a real
bank the customer name is unlikely to be a primary key, since two customers
could have the same name, we use a simplified schema where we assume that
names are unique.We allow customers to have more than one account, and more
than one loan.
branch(branch_name, branch_city, assets)
customer (customer_name, customer_street, customer_city)
loan (loan_number, branch_name, amount)
borrower (customer_name, loan_number)
account (account_number, branch_name, balance)
depositor (customer_name, account_number)
7
2. The foreign keys are as follows :
i. Forloan : branch_name referencing branch.
ii. Forborrower : Attribute customer_name referencing customer and
loan_number referencing loan
iii. For account : branch_name referencing branch.
iv. Fordepositor : Attribute customer_name referencing customer and
account_number referencing account
Question 2.10 : Consider the advisor relation shown in Figure 2.8, with s_id as
the primary key of advisor. Suppose a student can have more than one advisor.
Then, would s id still bea primary key of the advisor relation? If not, what should
the primary key of advisor be?
Answer : No, s_id would not be a primary key, since there may be two (or more)
tuples for a single student, correspondingto two (or more) advisors. The primary
key should then be s_id, i_id.
Question 2.11 : Describe the differences in meaning between the terms relation
and relation schema.
Answer : A relation schema is a type definition,and a relation is an instance of
that schema. For example, student (ss#, name) is a relation schema and
123-456-222 John
234-567-999 Mary
is a relation based on that schema.
Question 2.12 : Consider the relational database of Figure 2.14. Give an
expression in the relational algebra to express each of the following queries :
a. Find the names of all employees who work for “First Bank Corporation”.
b. Find the names and cities of residence of all employees who work for “First
Bank Corporation”.
c. Find the names,street address,and cities of residence of all employees who
work for “First Bank Corporation” and earn more than $10,000.
Answer :
a. Πperson_name (σcompany_name = “First Bank Corporation” (works))
b. Πperson_name,city (employee |×| (σcompany_name = “First Bank Corporation” (works)))
8
c. Πperson_name, street, city (σcompany_name = “First Bank Corporation” ∧ salary > 10000)
(works |×| employee))
Question 2.13 : Consider the bank database of Figure 2.15. Give an expression
in the relational algebra for each of the following queries:
a. Find all loan numbers with a loan value greater than $10,000.
b. Find the names of all depositors who have an account with a value greater than
$6,000.
c. Find the names of all depositors who have an account with a value greater than
$6,000 at the “Uptown” branch.
Answer:
a. Πloan_number (σamount > 10000(loan) )
b. Πcustomer_name (σbalance> 6000 (depositor |×| account))
c. Πcustomer_name (σbalance> 6000∧branch_name=“Uptown” (depositor |×| account))
Question 2.14 : List two reasons why null values might be introduced into the
database.
Answer : Nulls may be introduced into the database because the actual value is
either unknown or does not exist.For example,an employee whose address has
changed and whose new address is not yet known should be retained with a null
address. If employee tupleshave a composite attribute dependents, and a
particular employee has no dependents, then that tuple’s dependents attribute
should be given a null value.
Question 2.15 : Discuss the relative merits of procedural and nonprocedural
languages.
Answer : Nonprocedural languages greatly simplify the specification of queries
(at least, the types of queries they are designed to handle). The free the user from
having to worry abouthow the query is to be evaluated; not only does this reduce
programming effort, but in fact in most situations the query optimizer can do a
much better task of choosing the best way to evaluate a query than a programmer
working by trial and error. On the other hand, procedurallanguages are far more
powerful in terms of what computations they can perform. Some tasks can either
not be done using nonprocedural languages, or are very hard to express using
nonprocedural languages, or execute very inefficiently if specified in a
nonprocedural manner.

More Related Content

What's hot

Message and Stream Oriented Communication
Message and Stream Oriented CommunicationMessage and Stream Oriented Communication
Message and Stream Oriented CommunicationDilum Bandara
 
Socket Programming
Socket ProgrammingSocket Programming
Socket ProgrammingCEC Landran
 
Dbms Notes Lecture 9 : Specialization, Generalization and Aggregation
Dbms Notes Lecture 9 : Specialization, Generalization and AggregationDbms Notes Lecture 9 : Specialization, Generalization and Aggregation
Dbms Notes Lecture 9 : Specialization, Generalization and AggregationBIT Durg
 
1.10. pumping lemma for regular sets
1.10. pumping lemma for regular sets1.10. pumping lemma for regular sets
1.10. pumping lemma for regular setsSampath Kumar S
 
Os lab file c programs
Os lab file c programsOs lab file c programs
Os lab file c programsKandarp Tiwari
 
Language for specifying lexical Analyzer
Language for specifying lexical AnalyzerLanguage for specifying lexical Analyzer
Language for specifying lexical AnalyzerArchana Gopinath
 
Context model
Context modelContext model
Context modelUbaid423
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Ravindra Raju Kolahalam
 
Subnetting supernetting
Subnetting supernettingSubnetting supernetting
Subnetting supernettingwacasr12
 
Congestion control
Congestion controlCongestion control
Congestion controlAman Jaiswal
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relationalJafar Nesargi
 
Implementation of lexical analyser
Implementation of lexical analyserImplementation of lexical analyser
Implementation of lexical analyserArchana Gopinath
 
Functional dependancy
Functional dependancyFunctional dependancy
Functional dependancyVisakh V
 
Data Link Layer Numericals
Data Link Layer NumericalsData Link Layer Numericals
Data Link Layer NumericalsManisha Keim
 

What's hot (20)

Message and Stream Oriented Communication
Message and Stream Oriented CommunicationMessage and Stream Oriented Communication
Message and Stream Oriented Communication
 
Erd practice exercises
Erd practice exercisesErd practice exercises
Erd practice exercises
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 
Dbms Notes Lecture 9 : Specialization, Generalization and Aggregation
Dbms Notes Lecture 9 : Specialization, Generalization and AggregationDbms Notes Lecture 9 : Specialization, Generalization and Aggregation
Dbms Notes Lecture 9 : Specialization, Generalization and Aggregation
 
1.10. pumping lemma for regular sets
1.10. pumping lemma for regular sets1.10. pumping lemma for regular sets
1.10. pumping lemma for regular sets
 
Os lab file c programs
Os lab file c programsOs lab file c programs
Os lab file c programs
 
Distance vector routing
Distance vector routingDistance vector routing
Distance vector routing
 
Language for specifying lexical Analyzer
Language for specifying lexical AnalyzerLanguage for specifying lexical Analyzer
Language for specifying lexical Analyzer
 
Context model
Context modelContext model
Context model
 
Unit 2
Unit 2Unit 2
Unit 2
 
Chapter 10
Chapter 10Chapter 10
Chapter 10
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]
 
Subnetting supernetting
Subnetting supernettingSubnetting supernetting
Subnetting supernetting
 
Congestion control
Congestion controlCongestion control
Congestion control
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relational
 
Message passing in Distributed Computing Systems
Message passing in Distributed Computing SystemsMessage passing in Distributed Computing Systems
Message passing in Distributed Computing Systems
 
Implementation of lexical analyser
Implementation of lexical analyserImplementation of lexical analyser
Implementation of lexical analyser
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
 
Functional dependancy
Functional dependancyFunctional dependancy
Functional dependancy
 
Data Link Layer Numericals
Data Link Layer NumericalsData Link Layer Numericals
Data Link Layer Numericals
 

Similar to Database Assignment

CSI2132: Database I – Assignment 3:
CSI2132: Database I – Assignment 3:CSI2132: Database I – Assignment 3:
CSI2132: Database I – Assignment 3:DeanMurphys
 
DIRECTIONS READ THE FOLLOWING STUDENT POST AND RESPOND EVALUATE I.docx
DIRECTIONS READ THE FOLLOWING STUDENT POST AND RESPOND EVALUATE I.docxDIRECTIONS READ THE FOLLOWING STUDENT POST AND RESPOND EVALUATE I.docx
DIRECTIONS READ THE FOLLOWING STUDENT POST AND RESPOND EVALUATE I.docxlynettearnold46882
 
4. SQL in DBMS
4. SQL in DBMS4. SQL in DBMS
4. SQL in DBMSkoolkampus
 
Database Management System-session 3-4-5
Database Management System-session 3-4-5Database Management System-session 3-4-5
Database Management System-session 3-4-5Infinity Tech Solutions
 
Bca3020– data base management system(dbms)
Bca3020– data base management system(dbms)Bca3020– data base management system(dbms)
Bca3020– data base management system(dbms)smumbahelp
 
Introduction to database-Formal Query language and Relational calculus
Introduction to database-Formal Query language and Relational calculusIntroduction to database-Formal Query language and Relational calculus
Introduction to database-Formal Query language and Relational calculusAjit Nayak
 
Bca winter 2013 2nd sem
Bca winter 2013 2nd semBca winter 2013 2nd sem
Bca winter 2013 2nd semsmumbahelp
 
Database system by VISHAL PATIL
Database system by VISHAL PATILDatabase system by VISHAL PATIL
Database system by VISHAL PATILVishal Patil
 
2. Relational_Data_Model_Keys_10b.pptx
2. Relational_Data_Model_Keys_10b.pptx2. Relational_Data_Model_Keys_10b.pptx
2. Relational_Data_Model_Keys_10b.pptxvidyahulkman
 
Mi0034 database management systems
Mi0034  database management systemsMi0034  database management systems
Mi0034 database management systemssmumbahelp
 

Similar to Database Assignment (20)

SQL PPT.ppt
SQL PPT.pptSQL PPT.ppt
SQL PPT.ppt
 
CSI2132: Database I – Assignment 3:
CSI2132: Database I – Assignment 3:CSI2132: Database I – Assignment 3:
CSI2132: Database I – Assignment 3:
 
DIRECTIONS READ THE FOLLOWING STUDENT POST AND RESPOND EVALUATE I.docx
DIRECTIONS READ THE FOLLOWING STUDENT POST AND RESPOND EVALUATE I.docxDIRECTIONS READ THE FOLLOWING STUDENT POST AND RESPOND EVALUATE I.docx
DIRECTIONS READ THE FOLLOWING STUDENT POST AND RESPOND EVALUATE I.docx
 
IT 405
IT 405IT 405
IT 405
 
4. SQL in DBMS
4. SQL in DBMS4. SQL in DBMS
4. SQL in DBMS
 
Database Management System-session 3-4-5
Database Management System-session 3-4-5Database Management System-session 3-4-5
Database Management System-session 3-4-5
 
Unit04 dbms
Unit04 dbmsUnit04 dbms
Unit04 dbms
 
Bca3020– data base management system(dbms)
Bca3020– data base management system(dbms)Bca3020– data base management system(dbms)
Bca3020– data base management system(dbms)
 
Introduction to database-Formal Query language and Relational calculus
Introduction to database-Formal Query language and Relational calculusIntroduction to database-Formal Query language and Relational calculus
Introduction to database-Formal Query language and Relational calculus
 
DBMS-Unit-2.pptx
DBMS-Unit-2.pptxDBMS-Unit-2.pptx
DBMS-Unit-2.pptx
 
dbms first unit
dbms first unitdbms first unit
dbms first unit
 
DBMS Unit-2.pdf
DBMS Unit-2.pdfDBMS Unit-2.pdf
DBMS Unit-2.pdf
 
Bca winter 2013 2nd sem
Bca winter 2013 2nd semBca winter 2013 2nd sem
Bca winter 2013 2nd sem
 
Bc0041
Bc0041Bc0041
Bc0041
 
Database system by VISHAL PATIL
Database system by VISHAL PATILDatabase system by VISHAL PATIL
Database system by VISHAL PATIL
 
DBMS UNIT1
DBMS UNIT1DBMS UNIT1
DBMS UNIT1
 
Solution of Erds
Solution of ErdsSolution of Erds
Solution of Erds
 
L4_SQL.pdf
L4_SQL.pdfL4_SQL.pdf
L4_SQL.pdf
 
2. Relational_Data_Model_Keys_10b.pptx
2. Relational_Data_Model_Keys_10b.pptx2. Relational_Data_Model_Keys_10b.pptx
2. Relational_Data_Model_Keys_10b.pptx
 
Mi0034 database management systems
Mi0034  database management systemsMi0034  database management systems
Mi0034 database management systems
 

Recently uploaded

Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSAishani27
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiSuhani Kapoor
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystSamantha Rae Coolbeth
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...Florian Roscheck
 
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改atducpo
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...Suhani Kapoor
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfRachmat Ramadhan H
 
Aminabad Call Girl Agent 9548273370 , Call Girls Service Lucknow
Aminabad Call Girl Agent 9548273370 , Call Girls Service LucknowAminabad Call Girl Agent 9548273370 , Call Girls Service Lucknow
Aminabad Call Girl Agent 9548273370 , Call Girls Service Lucknowmakika9823
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Delhi Call girls
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiSuhani Kapoor
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptSonatrach
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 

Recently uploaded (20)

Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICS
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data Analyst
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
 
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
 
Aminabad Call Girl Agent 9548273370 , Call Girls Service Lucknow
Aminabad Call Girl Agent 9548273370 , Call Girls Service LucknowAminabad Call Girl Agent 9548273370 , Call Girls Service Lucknow
Aminabad Call Girl Agent 9548273370 , Call Girls Service Lucknow
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 

Database Assignment

  • 1. 1 Introduction to the Relational Model Question 1 : Define - Super Keys,Candidate Keys,Primary Keys with example. Answer : Super Keys : A super key is a combination of columns that uniquely identifies any row within a relational database management system (RDBMS) table.A candidate key is a closely related concept where the super key is reduced to the minimum number of columns required to uniquely identify each row. Candidate Keys : A candidate key is a column or set of columns in a table that can uniquely identify any database record without referring to any other data.Each table may have one or more candidate keys but one candidate key is unique and it is called the primary key. Primary Key : A primary key,also called a primary keyword is a key in a relational database that is unique for each record.It is a unique identifier such as a driver license number,telephone number (including area code) or vehicle identification number (VIN),A relational Database must always have one and only primary key. Lets take an example to understand super keys,candidate keys and primary key. Emp_SSN Emp_Number Emp_Name 123456789 226 Jayed 999999321 227 Lipi 888997212 228 Asik 777778888 229 Helal Super Keys :  {Emp_SSN}  {Emp_Number}  {Emp_SSN,Emp_Number}  {Emp_SSN,Emp_Number,Emp_Name}  {Emp_Number,Emp_Name} All of this above sets are able to uniquely identified. Candidate key: As stated above that they are the minimal super keys with no redundant attributes.
  • 2. 2  {Emp_SSN}  {Emp_Number} Only these two sets are candidate keys as another sets are having redundant attributes these are not necessary for unique identification. Primary Key : Primary key is being selected from the sets of candidate keys by database designer.So either {Emp_SSN} or {Emp_Number} can be the primary key. Question 2 : Write down any five symbols with examples of relational algebra. Answer : Symbol (Name) Example of Use σ (Selection) σ salary > = 85000 (instructor) Return rows of the input relation that satisfy the predicate. Π (Projection) Π ID, salary (instructor) Output specified attributes from all rows of the input relation. Remove duplicate tuples from the output x (Cartesian Product) instructor x department Output pairs of rows from the two input relations that have the same value on all attributes that have the same name ∪ (Union) Π name (instructor) ∪ Π name (student) Output the union of tuples from the two input relations. ⋈ (Natural Join) instructor ⋈ department Output pairs of rows from the two input relations that have the same value on all attributes that have the same name.
  • 3. 3 Solution Of Practice Exercises Question 2.1 : Consider the relational database of Figure 2.14 What are the appropriate primary keys? Answer : The answer is shown in Figure 2.1, with primary keys underlined. Question2.2 : Consider the foreign key constraint from the dept_name attribute of instructor to the department relation.Give examples of inserts and deletes to these relations,which can cause a violation of the foreign key constraint. Answer : Inserting a tuple : (10111, Ostrom, Economics, 110,000) Into the instructor table,where the department table does nothave the department Economics, would violate the foreign key constraint. Deleting the tuple : (Biology, Watson, 90000) from the department table, where at least one student or instructor tuple has dept name as biology, would violate the foreign key constraint. employee (person_name, street, city) works (person_name, company_name, salary) company (company_name, city) Figure 2.1 : Relational database for Practice Exercise 2.1. Question 2.3 : Consider the time_slot relation. Given that a particular time slot can meet more than once in a week, explain why day and start_time are part of the primary key of this relation, while end_time is not. Answer : The attributes day and start_time are part of the primary key since a particular class will most likely meet on several different days, and may even meet more than once in a day. However, end_time is not part of the primary key since a particular class that starts at a particular time on a particular day cannot end at more than one time. Question2.4 :In the instance of instructor shown in Figure??.. no two instructors have the same name. From this, can we conclude that name can be used as a superkey (or primary key) of instructor?
  • 4. 4 Answer : No. For this possible instance of the instructor table the names are unique, but in general this may not be always the case (unless the university has a rule that two instructors cannot have the same name, which is a rather unlikey scenario). Question2.5 : What is the result of first performing the cross productofstudent and advisor, and then performing a selection operation on the result with the predicate s_id = ID? (Using the symbolic notation ofrelational algebra, this query can be written as σs_id = ID(student × advisor).) Answer : The result attributes include all attribute values of student followed by all attributes of advisor. The tuples in the result are as follows. For each student who has an advisor, the result has a row containing that students attributes,followed by an s_id attribute identical to the students ID attribute, followed by the i_id attribute containing the ID of the students advisor. Students who do not have an advisor will not appear in the result. A student who has more than one advisor will appear a corresponding number of times in the result. Question 2.6 : Consider the following expressions, which use the result of a relational algebra operation as the input to another operation.For each expression, explain in words what the expression does. a. σyear ≥ 2009(takes) |×| student b. σyear ≥ 2009(takes |×| student) c. ΠID,name,course_id(student |×| takes) Answer : a. Foreach student who takes at least one course in 2009, display the students information along with the information about what courses the student took. The attributes in the result are: ID, name, dept_name, tot_cred, course_id, section_id, semester, year, grade b. Same as (a); selection can be done before the join operation. c. Provide a list of consisting of ID, name, course_id of all students who took any coursein the university. Question2.7 :Consider the relational database ofFigure 2.14 Give an expression in the relational algebra to express each of the following queries :
  • 5. 5 a. Find the names of all employees who live in city “Miami”. b. Find the names of all employees whose salary is greater than $100,000. c. Find the names of all employees who live in “Miami” and whose salary is greater than $100,000. Answer : a. Πname (σcity = “Miami” (employee)) b. Πname (σsalary >100000 (employee)) c. Πname (σcity = “Miami” ∧ salary>100000 (employee)) Question 2.8 : Consider the bank database of Figure 2.15 Give an expression in the relational algebra for each of the following queries. a. Find the names of all branches located in “Chicago”. b. Find the names of all borrowers who have a loan in branch “Downtown”. Answer: a. Πbranch_name (σbranch_city = “Chicago” (branch)) b. Πcustomer_name (σbranch_name = “Downtown” (borrower |× loan))
  • 6. 6 Solution Of Exercises Question 2.9 : Consider the bank database of Figure 2.15. a. What are the appropriate primary keys? b. Given your choice of primary keys,identify appropriate foreign keys. Answer : a. employee (person_name, street, city) works (person_name, company_name, salary) company (company_name, city) Figure 2.14 : Relational database for Exercises 2.1, 2.7, and 2.12. branch(branch_name, branch_city, assets) customer (customer_name, customer_street, customer_city) loan (loan_number, branch_name, amount) borrower (customer_name, loan_number) account (account_number, branch_name, balance) depositor (customer_name, account_number) Figure 2.15 : Banking database for Exercises 2.8, 2.9, and 2.13. b. 1. The primary keys of the various schema are underlined. Although in a real bank the customer name is unlikely to be a primary key, since two customers could have the same name, we use a simplified schema where we assume that names are unique.We allow customers to have more than one account, and more than one loan. branch(branch_name, branch_city, assets) customer (customer_name, customer_street, customer_city) loan (loan_number, branch_name, amount) borrower (customer_name, loan_number) account (account_number, branch_name, balance) depositor (customer_name, account_number)
  • 7. 7 2. The foreign keys are as follows : i. Forloan : branch_name referencing branch. ii. Forborrower : Attribute customer_name referencing customer and loan_number referencing loan iii. For account : branch_name referencing branch. iv. Fordepositor : Attribute customer_name referencing customer and account_number referencing account Question 2.10 : Consider the advisor relation shown in Figure 2.8, with s_id as the primary key of advisor. Suppose a student can have more than one advisor. Then, would s id still bea primary key of the advisor relation? If not, what should the primary key of advisor be? Answer : No, s_id would not be a primary key, since there may be two (or more) tuples for a single student, correspondingto two (or more) advisors. The primary key should then be s_id, i_id. Question 2.11 : Describe the differences in meaning between the terms relation and relation schema. Answer : A relation schema is a type definition,and a relation is an instance of that schema. For example, student (ss#, name) is a relation schema and 123-456-222 John 234-567-999 Mary is a relation based on that schema. Question 2.12 : Consider the relational database of Figure 2.14. Give an expression in the relational algebra to express each of the following queries : a. Find the names of all employees who work for “First Bank Corporation”. b. Find the names and cities of residence of all employees who work for “First Bank Corporation”. c. Find the names,street address,and cities of residence of all employees who work for “First Bank Corporation” and earn more than $10,000. Answer : a. Πperson_name (σcompany_name = “First Bank Corporation” (works)) b. Πperson_name,city (employee |×| (σcompany_name = “First Bank Corporation” (works)))
  • 8. 8 c. Πperson_name, street, city (σcompany_name = “First Bank Corporation” ∧ salary > 10000) (works |×| employee)) Question 2.13 : Consider the bank database of Figure 2.15. Give an expression in the relational algebra for each of the following queries: a. Find all loan numbers with a loan value greater than $10,000. b. Find the names of all depositors who have an account with a value greater than $6,000. c. Find the names of all depositors who have an account with a value greater than $6,000 at the “Uptown” branch. Answer: a. Πloan_number (σamount > 10000(loan) ) b. Πcustomer_name (σbalance> 6000 (depositor |×| account)) c. Πcustomer_name (σbalance> 6000∧branch_name=“Uptown” (depositor |×| account)) Question 2.14 : List two reasons why null values might be introduced into the database. Answer : Nulls may be introduced into the database because the actual value is either unknown or does not exist.For example,an employee whose address has changed and whose new address is not yet known should be retained with a null address. If employee tupleshave a composite attribute dependents, and a particular employee has no dependents, then that tuple’s dependents attribute should be given a null value. Question 2.15 : Discuss the relative merits of procedural and nonprocedural languages. Answer : Nonprocedural languages greatly simplify the specification of queries (at least, the types of queries they are designed to handle). The free the user from having to worry abouthow the query is to be evaluated; not only does this reduce programming effort, but in fact in most situations the query optimizer can do a much better task of choosing the best way to evaluate a query than a programmer working by trial and error. On the other hand, procedurallanguages are far more powerful in terms of what computations they can perform. Some tasks can either not be done using nonprocedural languages, or are very hard to express using nonprocedural languages, or execute very inefficiently if specified in a nonprocedural manner.