Using the four tables I need help anwsering the problems below DROP TABLE Outcomes; DROP TABLE Battles; DROP TABLE Ships; DROP TABLE Classes; CREATE TABLE Classes ( className VARCHAR2(20), typeClass CHAR(2), country VARCHAR2(15), numGuns INTEGER, bore INTEGER, displacement INTEGER); CREATE TABLE Ships ( shipName VARCHAR2(20), shipClass VARCHAR2(20), launchYr INTEGER); CREATE TABLE Battles ( battleName VARCHAR2(20), battleYr INTEGER); CREATE TABLE Outcomes ( ship VARCHAR2(20), battle VARCHAR2(20), outcome VARCHAR2(10)); INSERT INTO Classes VALUES ('Iowa', 'bb', 'USA', 9, 16, 46000); INSERT INTO Ships VALUES ('Missouri', 'Iowa', 1944); INSERT INTO Battles VALUES ('Surigao Strait', 1944); INSERT INTO Outcomes (ship, battle, outcome) VALUES ('Missouri', 'Surigao Strait', 'ok'); COMMIT; Unique SQL statements are needed: 1. You want to specify that we cannot have 2 different outcomes for a ship in a battle. What constraint will you use for this? Write an SQL ALTER TABLE statement to specify this constraint. (Check the following statement gives an error: INSERT INTO Outcomes (ship, battle) VALUES ('Missouri', 'Surigao Strait');). 2. You want to specify that no 2 battles have the same battleName. What constraint will you use for this? Write an SQL ALTER TABLE statement to specify this constraint. (Check the following statement given an error: INSERT INTO Battles (battleName) VALUES ('Surigao Strait');) 3. You want to specify that the only values that are allowed for typeClass in the Classes table are bb and bc. What constraint will you use for this? Write an SQL ALTER TABLE statement to specify this constraint. (check that the following statement gives an error: INSERT INTO Classes(className, typeClass) VALUES ('Kongo', 'aa');) Please explain as well I need to practice
Concepts in Designing Database
A database design is the process of data organization based on a database model. The process deals with identifying what data should be stored in a database and how data elements relate to each other.
Entity Relationship Diagram
Complex real-world applications call for large volumes of data. Therefore, it is necessary to build a great database to store data safely and coherently. The ER data model aids in the process of database design. It helps outline the structure of an organization’s database by understanding the real-world interactions of objects related to the data. For example, if a school is tasked to store student information, then analyzing the correlation between the students, subjects, and teachers would help identify how the data needs to be stored.
Using the four tables I need help anwsering the problems below
DROP TABLE Outcomes;
DROP TABLE Battles;
DROP TABLE Ships;
DROP TABLE Classes;
CREATE TABLE Classes (
className VARCHAR2(20),
typeClass CHAR(2),
country VARCHAR2(15),
numGuns INTEGER,
bore INTEGER,
displacement INTEGER);
CREATE TABLE Ships (
shipName VARCHAR2(20),
shipClass VARCHAR2(20),
launchYr INTEGER);
CREATE TABLE Battles (
battleName VARCHAR2(20),
battleYr INTEGER);
CREATE TABLE Outcomes (
ship VARCHAR2(20),
battle VARCHAR2(20),
outcome VARCHAR2(10));
INSERT INTO Classes VALUES ('Iowa', 'bb', 'USA', 9, 16, 46000);
INSERT INTO Ships VALUES ('Missouri', 'Iowa', 1944);
INSERT INTO Battles VALUES ('Surigao Strait', 1944);
INSERT INTO Outcomes (ship, battle, outcome) VALUES ('Missouri', 'Surigao Strait',
'ok');
COMMIT;
Unique SQL statements are needed:
1. You want to specify that we cannot have 2 different outcomes for a ship in a battle. What
constraint will you use for this? Write an SQL ALTER TABLE statement to specify this
constraint.
(Check the following statement gives an error: INSERT INTO Outcomes (ship, battle)
VALUES ('Missouri', 'Surigao Strait');).
2. You want to specify that no 2 battles have the same battleName. What constraint will you use
for this? Write an SQL ALTER TABLE statement to specify this constraint.
(Check the following statement given an error: INSERT INTO Battles (battleName)
VALUES ('Surigao Strait');)
3. You want to specify that the only values that are allowed for typeClass in the Classes table
are bb and bc. What constraint will you use for this? Write an SQL ALTER TABLE
statement to specify this constraint.
(check that the following statement gives an error: INSERT INTO Classes(className,
typeClass) VALUES ('Kongo', 'aa');)
Please explain as well I need to practice
Trending now
This is a popular solution!
Step by step
Solved in 6 steps