The document contains solutions to exercises on designing ER diagrams and mapping them to SQL schemas. The problems provide scenarios about entities like employees, departments, artwork, artists, customers etc. and their relationships. The solutions involve drawing the ER diagrams
Normalization is the process of removing redundant data from your tables to improve storage efficiency, data integrity, and scalability.
Normalization generally involves splitting existing tables into multiple ones, which must be re-joined or linked each time a query is issued.
Why normalization?
The relation derived from the user view or data store will most likely be unnormalized.
The problem usually happens when an existing system uses unstructured file, e.g. in MS Excel.
Normalization is the process of removing redundant data from your tables to improve storage efficiency, data integrity, and scalability.
Normalization generally involves splitting existing tables into multiple ones, which must be re-joined or linked each time a query is issued.
Why normalization?
The relation derived from the user view or data store will most likely be unnormalized.
The problem usually happens when an existing system uses unstructured file, e.g. in MS Excel.
Database normalization is the process of refining the data in accordance with a series of normal forms. This is done to reduce data redundancy and improve data integrity. This process divides large tables into small tables and links them using relationships.
Here is the link of full article: https://www.support.dbagenesis.com/post/database-normalization
● Data Modeling and Data Models.
● Business Rules (Translating Business Rules into Data Model Components).
● Emerging Data Models: Big Data and NoSQL.
● Degrees of Data Abstraction (External, Conceptual, Internal and Physical model).
The importance of software since there is were the motivation for software engineering lies and then and introduction to software engineering mentioning the concept and stages of development and working in teams
Database normalization is the process of refining the data in accordance with a series of normal forms. This is done to reduce data redundancy and improve data integrity. This process divides large tables into small tables and links them using relationships.
Here is the link of full article: https://www.support.dbagenesis.com/post/database-normalization
● Data Modeling and Data Models.
● Business Rules (Translating Business Rules into Data Model Components).
● Emerging Data Models: Big Data and NoSQL.
● Degrees of Data Abstraction (External, Conceptual, Internal and Physical model).
The importance of software since there is were the motivation for software engineering lies and then and introduction to software engineering mentioning the concept and stages of development and working in teams
Sass Code Reviews - How one code review changed my life #SassConf2015Stacy Kvernmo
After writing CSS for over 10 years you'd think you would know everything there is to know, right? I couldn't be more wrong and I found out the hard way. While my first formal code review session was painfully embarrassing it was also the most important lesson I have learned throughout my career. Code reviews force you to communicate on a different level which ultimately leads to more thoughtful coding practices. When writing Sass and other pre-processed languages it is even more important that you review your code continually, which even the more seasoned front end developers may neglect at times.
Bottom line: Code reviews will make you better.
For this Applied Knowledge Assessment, you will use the concepts.docxAKHIL969626
For this Applied Knowledge Assessment, you will use the concepts learned throughout this unit. You will develop your understanding of nets, perimeter, and area. Refer back to individual lessons if you need help.
Nets in the Kitchen
This assessment is worth 75 points. Show all work on this sheet and submit one document for full credit.
Part 1: Nets
Recall (refer to page 12 in your textbook if necessary) that a net is a two-dimensional pattern that you can fold to form a three-dimensional figure. You are to create nets for two different boxes from your house. Some good box examples include: cereal boxes, pasta boxes, cracker boxes, etc.
1. Rummage through your house and locate the two different boxes that you will use for this activity.
2. In the space provided below, describe what your original box looks like in a few sentences. You may also take pictures of your box and insert them into this document; however, this is not mandatory. When describing each three-dimensional figure, be sure to use complete sentences and proper grammar/spelling.
3. Create a net for each box. You may cut the box to help you unfold it into a two-dimensional piece.
4. Sketch your net in the space provided below. You must sketch your net by hand. The size of the net will not be drawn to scale. Draw each net to fit in the provided space. Use a ruler or other straight edge to make neat, straight lines.
Part 2: Perimeter and Area
Part 2 of this assessment will focus on perimeter and area. Choose one of your boxes from Part 1 to complete this activity. You will need a ruler. If you do not have one available, you may visit the following link to print and cut out a ruler:
http://www.vendian.org/mncharity/dir3/paper_rulers/UnstableURL/ruler_foot.pdf
1. Measure the top of your box. Draw a picture of the top of the box. Include your measurements and label the units. You may use inches or centimeters for the units. (Be sure to use the same units for the remainder of Part 2.)
2. What is the perimeter and area of the top of the box? Show all work and include the proper units.
3. Measure the front of your box. Draw a picture of the front of the box. Include your measurements and label the units.
4. What is the perimeter and area of the front of the box? Show all work and include the proper units.
5. Measure the bottom of the box. Draw a picture of the bottom of the box. Include your measurements and label the units.
6. What is the perimeter and area of the bottom of the box? Show all work and include the proper units.
7. Compare the areas of the pieces of the box. Which pieces have the same area? Why?
8. There are some pieces of the box that we did not measure. Use your knowledge of area and your findings from the previous questions to infer which pieces of the box will have the same area (you do not need to calculate the actual areas here). Be sure to list all parts of the box (top, bottom, front, back, side 1, and side 2).
Directions for Inserting an Image i ...
33.value10.00 pointsGeppetto and Lewis decide that they.docxtamicawaysmith
33.
value:
10.00 points
Geppetto and Lewis decide that they would like to trade puzzles and puppets in order to better stock their toy store shelves. The table below compares their production possibilities schedules.
Production Possibilities Schedules
Geppetto
Lewis
Puzzles
Puppets
Puzzles
Puppets
100
0
50
0
80
4
40
5
60
8
30
10
40
12
20
15
20
16
10
20
0
20
0
25
The two toy store owners agree to specialize and to trade 30 puzzles for 10 puppets. The terms of trade are still 3 puzzles for each puppet.
After they complete their trade, Geppetto will have puzzles and puppets and Lewis will have puzzles and puppets.
34.
value:
10.00 points
Ireland and Scotland both produce potatoes and sausages. The table below presents their production possibilities schedules.
Production Possibilities Schedules
Ireland
Scotland
Potatoes
(tons)
Sausage
(tons)
Potatoes
(tons)
Sausage
(tons)
0
150
0
200
100
120
50
160
200
90
100
120
300
60
150
80
400
30
200
40
500
0
250
0
Using the three combined amounts of production, graph the combined production possibilities frontier for Ireland and Scotland.
Instructions: Use the tool provided 'PPF' to plot the combined production possibilities frontier point by point (3 points total).
40.
value:
10.00 points
Barney decides to quit his job as a corporate accountant (which pays $10,000 a month) and go into business for himself as a certified public accountant. He decides not to rent office space downtown, but instead sets up shop in his converted garage apartment, which he could rent out for $300 a month if he wasn’t using it as his own office. He must purchase office supplies worth $75 a month, and his monthly electricity bill has increased by $50 now that he is working out of his home office. After six months of working from home, Barney has earned an average of $12,000 per month.
a. What are Barney’s average monthly accounting profits?
$
b. What are Barney’s average monthly economic profits?
$
42.
value:
10.00 points
A young Thomas Edison makes 20 light bulbs a week in his dorm room. The parts for each light bulb cost $2.00. He sells each light bulb for $5.00. General Electric offers Thomas an executive job that pays $50.00 a week. Thomas’s weekly economic profit from making light bulbs is equal to:
$.
43.
value:
10.00 points
Estella decides to set up a lemonade stand on a hot summer day. Before long, Estella’s friends all decide they would like to help. The table below shows what happens to the number of glasses of lemonade Estella and her friends can make in an hour.
Lemonade Production
Labor (workers)
Total Product
Average Product
Marginal Product
0
0
—
—
1 (Estella)
9
—
2
18
3
24
4
28
5
25
e. How many additional glasses of lemonade can Estella produce if she has four friends help her rather than three friends help her?
glasse ...
DIRECTIONS READ THE FOLLOWING STUDENT POST AND RESPOND EVALUATE I.docxlynettearnold46882
DIRECTIONS: READ THE FOLLOWING STUDENT POST AND RESPOND EVALUATE ITS CONTENT. PLEASE CITE ALL REFERENCES
Katie Kessler
Unit 2 Discussion 1
Top of Form
The word “noir” is used to remember the scaling of measurement in psychology (Embretson, 2004). In short, the letters stand for nominal, ordinal, interval and ratio (Embretson, 2004). To give a brief introduction of what each scale measures, “nominal is the simplest way to measure” because it focuses on categorizing measurements on a scale of category, according to Embretson (2004). An example of nominal is eye color. “Ordinal measures in terms of ranking, interval measures scores of tests that focus on unobservable mental functioning and ratio focuses on measuring activities in the physical world, such as someone’s running time” (Embretson, 2004). With different scales of measurement, there are two methods to compare sets of data. These include norm-referenced and criterion-referenced testing. According to Embretson (2004) norm-referenced testing “yields information on a testtaker’s standing or ranking relative to some comparison group of testtakers.” In other words, it focuses on the performance of peers. Criterion-referenced testing is a little different because it focuses on examining individual’s scores to a set standard (Embretson, 2004).
The ability for ordinal measurement scale to be utilized on a standardized test as a norm-referenced test is high since an ordinal scale is based upon ranking and norm-referenced testing gathers information on the examinees ranking compared to a group of testtakers. For example, a study conducted on decision making with the use of ordinal variables states that ordinal measurement scales has the ability to be utilized by norm-referenced testing (Barua, Kademane, Das, Gubbiyappa, Verma, & Al-Dubai, 2014).On the other hand, ordinal scaling would not be a strong measurement for criterion-referenced testing because it focuses on the ranking rather than the measurement of the scores to be close to a set standard.
Ratio scaling directs its focus on measuring objects and activities in the physical world which would be beneficial for criterion-referenced testing instead of norm-referenced testing. Imagine a marathon runner who was trying to beat the world’s fastest time running a marathon. Criterion-referenced testing allows the runner to be aware of the set standard the marathon runner needs to beat to be the best and set a new standard. Norm-referenced testing would not be as useful because the marathon runner would not have the standard measurement he or she needs to beat. However, the marathon runner would be aware of the relative time he or she needs to beat to be the best. That is not as helpful as the criterion-referenced testing because runners need an exact number instead of a relative number in comparison to other runners.
Norm-referenced data would be collected by “the standards relative to a group, such as means and standard deviation.
The joint task force of ACM and IEEE Computer Society released recent guidelines for undergraduate computer science majors late in 2013. Since that time, many computer science departments have reviewed the included recommendations and exemplars from various institutions, and made changes to the programs that they offer. In this panel, we will share the experiences of the panelists from a variety of computer science programs in reviewing and responding to the new curriculum guidelines. The panel hopes to generate additional discussion about new knowledge areas and models for incorporating recommended content into programs at small, liberal arts institutions.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Honest Reviews of Tim Han LMA Course Program.pptxtimhan337
Personal development courses are widely available today, with each one promising life-changing outcomes. Tim Han’s Life Mastery Achievers (LMA) Course has drawn a lot of interest. In addition to offering my frank assessment of Success Insider’s LMA Course, this piece examines the course’s effects via a variety of Tim Han LMA course reviews and Success Insider comments.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
2. Exercise 2.4
Problem
• A company database needs to store
information about employees (identified by
ssn, with salary and phone as attributes),
departments (identified by dno, with dname
and budget as attributes), and children of
employees (with name and age as attributes).
3. Exercise 2.4
Problem
• Employees work in departments; each
department is managed by an employee; a child
must be identified uniquely by name when the
parent (who is an employee; assume that only
one parent works for the company) is known. We
are not interested in information about a child
once the parent leaves the company.
• Draw an ER diagram that captures this
information.
4. Exercise 2.4
Solution
• First, we shall design the entities and
relationships.
– “Employees work in departments…”
– “…each department is managed by an
employee…”
– “…a child must be identified uniquely by name
when the parent (who is an employee; assume
that only one parent works for the company) is
known.”
6. Exercise 2.4
Solution
• Now, we will design the constraints.
– “…each department is managed by an
employee…”
– “…a child must be identified uniquely by name
when the parent (who is an employee; assume
that only one parent works for the company) is
known. “
– “We are not interested in information about a
child once the parent leaves the company.”
8. Exercise 2.8
Problem
• Although you always wanted to be an artist, you
ended up being an expert on databases because
you love to cook data and you somehow
confused database with data baste. Your old love
is still there, however, so you set up a database
company, ArtBase, that builds a product for art
galleries. The core of this product is a database
with a schema that captures all the information
that galleries need to maintain.
9. Exercise 2.8
Problem
• Galleries keep information about artists, their
names (which are unique), birthplaces, age,and
style of art. For each piece of artwork, the artist,
the year it was made, its unique title, its type of
art (e.g., painting, lithograph, sculpture,
photograph), and its price must be stored. Pieces
of artwork are also classified into groups of
various kinds, for example, portraits, still lifes,
works by Picasso, or works of the 19th century; a
given piece may belong to more than one group.
10. Exercise 2.8
Problem
• Each group is identified by a name (like those
just given) that describes the group. Finally,
galleries keep information about customers.
For each customer, galleries keep that person’s
unique name, address, total amount of dollars
spent in the gallery (very important!), and the
artists and groups of art that the customer
tends to like.
• Draw the ER diagram for the database.
11. Exercise 2.8
Solution
• Like before, we begin with the entities and
relationships.
• “…artists, their names (which are unique),
birthplaces, age, and style of art.”
• “For each piece of artwork, the artist, the year
it was made, its unique title, its type of art …
and its price must be stored.”
12. Exercise 2.8
Solution
• “Pieces of artwork are also classified into
groups of various kinds, … Each group is
identified by a name (like those just given)
that describes the group. “
• For each customer, galleries keep that person’s
unique name, address, total amount of dollars
spent in the gallery (very important!), and the
artists and groups of art that the customer
tends to like.
15. Exercise 2.8
Solution
• Now we look at constraints.
– Although not explicitly mentioned in the problem,
we assume that each piece of artwork had to be
painted by an artist.
– We also assume that each piece of artwork was
created by exactly one artist.
17. Exercise 2.8
Solution
• Suppose we had several piece of artwork with
the same title, and we told them apart by
artist?
• Example: “What is Love?” by Cheryl D, “What
is Love?” by Joe Brown, etc.
19. Exercise 3.14
Problem
• Consider the scenario from Exercise 2.4,
where you designed an ER diagram for a
company database. Write SQL statements to
create the corresponding relations and
capture as many of the constraints as possible.
If you cannot capture some constraints,
explain why.
23. Exercise 3.14
Solution
• Next, we translate the relationships, Manages
and Dependents.
• We translate each these to a table mapping
one entity to another.
• We also use foreign constraints to make sure
every row in the relationship tables refers only
to rows that exist in the entity tables.
25. Exercise 3.14
Solution
• Why did we make dno the primary key for
Manages?
• Since each department can have at most one
manager, each dno can appear at most once in
the Manages table, making it a key for
Manages.
• Note that if we had made (ssn, dno) the key
for Manages, a department could have more
than one Manager.
27. Exercise 3.14
Solution
CREATE TABLE Dependents(
ssn CHAR(10),
name CHAR(10),
age INTEGER,
PRIMARY KEY (ssn, name),
FOREIGN KEY (ssn)
REFERENCES Employees,
ON DELETE CASCADE )
28. Exercise 3.18
Problem
• Write SQL statements to create the
corresponding relations to the ER diagram you
designed for Exercise 2.8. If your translation
cannot capture any constraints in the ER
diagram, explain why.
30. Exercise 3.18
Solution
• The entities are translated similarly to Exercise
3.4. Since these are fairly simple, we shall skip
them.
• Now, we shall translate the relationships.
31. Exercise 3.18
Solution
CREATE TABLE Like Group (
name CHAR(20),
cust name CHAR(20),
PRIMARY KEY (name, cust_name),
FOREIGN KEY (name)
REFERENCES Group,
FOREIGN KEY (cust name)
REFERENCES Customer)
32. Exercise 3.18
Solution
CREATE TABLE Like Artist (
name CHAR(20),
cust name CHAR(20),
PRIMARY KEY (name, cust name),
FOREIGN KEY (name) REFERENCES Artist,
FOREIGN KEY (cust name) REFERENCES Customer)
33. Exercise 3.18
Solution
CREATE TABLE Artwork Paints(
title CHAR(20),
artist name CHAR(20),
type CHAR(20),
price INTEGER,
year INTEGER,
PRIMARY KEY (title),
FOREIGN KEY (artist name)
REFERENCES Artist)
34. Exercise 3.18
Solution
CREATE TABLE Classify (
title CHAR(20),
name CHAR(20),
PRIMARY KEY (title, name),
FOREIGN KEY (title) REFERENCES Artwork_Paints,
FOREIGN KEY (name) REFERENCES Group )
35. Exercise 3.8
Problem
• Answer each of the following questions
briefly. The questions are based on the
following relational schema:
– Emp(eid: integer, ename: string, age: integer,
salary: real)
– Works(eid: integer, did: integer, pcttime: integer)
– Dept(did: integer, dname: string, budget: real,
managerid: integer)
36. Exercise 3.8
Problem
Emp(eid: integer, ename: string, age: integer, salary: real)
Works(eid: integer, did: integer, pcttime: integer)
Dept(did: integer, dname: string, budget: real, managerid: integer
1. Give an example of a foreign key constraint
that involves the Dept relation. What are the
options for enforcing this constraint when a
user attempts to delete a Dept tuple?
37. Exercise 3.8
Solution for (1)
An example of a foreign constraint that
involves Dept is:
CREATE TABLE Works (
eid INTEGER NOT NULL ,
did INTEGER NOT NULL ,
pcttime INTEGER,
PRIMARY KEY (eid, did),
UNIQUE (eid),
FOREIGN KEY (did) REFERENCES Dept )
38. Exercise 3.8
Solution for (1)
Furthermore, when a user attempts to delete
a tuple from Dept, we can
– also delete all Works tuples that refer to it.
– disallow the deletion of the Dept tuple if some
Works tuple refers to it.
– for every Works tuple that refers to it, set the did
field to the did of some (existing) ’default’
department.
– for every Works tuple that refers to it, set the did
field to null.
39. Exercise 3.8
Problem
Emp(eid: integer, ename: string, age: integer, salary: real)
Works(eid: integer, did: integer, pcttime: integer)
Dept(did: integer, dname: string, budget: real, managerid: integer
2. Write the SQL statements required to create
the preceding relations, including
appropriate versions of all primary and
foreign key integrity constraints.
41. Exercise 3.8
Solution for (2)
Dept(did: integer, dname: string, budget: real, managerid: integer
CREATE TABLE Dept (
did INTEGER,
budget REAL,
managerid INTEGER ,
PRIMARY KEY (did),
FOREIGN KEY (managerid) REFERENCES Emp,
ON DELETE SET NULL)
42. Exercise 3.8
Problem
Emp(eid: integer, ename: string, age: integer, salary: real)
Works(eid: integer, did: integer, pcttime: integer)
Dept(did: integer, dname: string, budget: real, managerid: integer
3. Define the Dept relation in SQL so that every
department is guaranteed to have a manager.
CREATE TABLE Dept (
did INTEGER,
budget REAL,
managerid INTEGER NOT NULL ,
PRIMARY KEY (did),
FOREIGN KEY (managerid) REFERENCES Emp)
Example of a Solution for (3)
43. Exercise 3.8
Problem
Emp(eid: integer, ename: string, age: integer, salary: real)
Works(eid: integer, did: integer, pcttime: integer)
Dept(did: integer, dname: string, budget: real, managerid: integer
4. Write an SQL statement to add John Doe as
an employee with eid = 101, age = 32 and
salary = 15, 000.
INSERT
INTO Emp (eid, ename, age, salary)
VALUES (101, ’John Doe’, 32, 15000)
Solution for (4)
44. Exercise 3.8
Problem
Emp(eid: integer, ename: string, age: integer, salary: real)
Works(eid: integer, did: integer, pcttime: integer)
Dept(did: integer, dname: string, budget: real, managerid: integer
5. Write an SQL statement to give every
employee a 10 percent raise.
UPDATE Emp E
SET E.salary = E.salary * 1.10
Solution for (5)
45. Exercise 3.8
Problem
Emp(eid: integer, ename: string, age: integer, salary: real)
Works(eid: integer, did: integer, pcttime: integer)
Dept(did: integer, dname: string, budget: real, managerid: integer
6. Write an Write an SQL statement to delete
the Toy department. Given the referential
integrity constraints you chose for this
schema, explain what happens when this
statement is executed.
46. Exercise 3.8
Solution for (6)
DELETE
FROM Dept D
WHERE D.dname = ’Toy’
Since the action to take on deletion was not
specified, the database takes no action by default
That is, it rejects the deletion.
CREATE TABLE Works (
…
FOREIGN KEY (did) REFERENCES Dept,
…)
These are the example integrity constraints that
affect Dept.
47. Exercise 3.8
Solution for (6)
• What other actions can the system take on
deleting a Dept tuple? What are the pros and
cons of each action?
– On delete set null
– On delete set default
– On delete cascade
48. This is the end of the lecture!
I hope you enjoyed it.