Write the SQL statement to define a view for cheap computers, the view has model, speed, ram, hd, and price information for computers (PCs or Laptops) with price < $990. Write an SQL query using the above view to find manufacturers of cheap computers. Use ALTER TABLE to add a CHECK constraint to enforce that speed of a laptop must be greater than 2.1. Use ALTER TABLE to add a CHECK constraint to enforce that the type of a printer must be ‘ink-jet’, ‘laser’, or 'bubble-jet'. Use ALTER TABLE to add a CHECK constraint to enforce that the price of a PC must be at least $500, and at most $4000
DROP TABLE Printer CASCADE CONSTRAINTS;
DROP TABLE Laptop CASCADE CONSTRAINTS;
DROP TABLE PC CASCADE CONSTRAINTS;
DROP TABLE Product CASCADE CONSTRAINTS;
CREATE TABLE Product ( maker VARCHAR(20),
model INT PRIMARY KEY,
type VARCHAR(10)
);
CREATE TABLE PC ( model INT PRIMARY KEY,
speed NUMBER (4,2),
ram INT,
hd INT,
price NUMBER (7,2)
);
CREATE TABLE Laptop ( model INT PRIMARY KEY,
speed NUMBER (4,2),
ram INT,
hd INT,
screen NUMBER (3,1),
price NUMBER (7,2)
);
CREATE TABLE Printer ( model INT PRIMARY KEY,
color CHAR (6),
type VARCHAR(10),
price NUMBER (7,2)
);
Write the SQL statement to define a view for cheap computers, the view has model,
speed, ram, hd, and price information for computers (PCs or Laptops) with price < $990.
Write an SQL query using the above view to find manufacturers of cheap computers.
Use ALTER TABLE to add a CHECK constraint to enforce that speed of a laptop must
be greater than 2.1.
Use ALTER TABLE to add a CHECK constraint to enforce that the type of a printer
must be ‘ink-jet’, ‘laser’, or 'bubble-jet'.
Use ALTER TABLE to add a CHECK constraint to enforce that the price of a PC must
be at least $500, and at most $4000
Step by step
Solved in 5 steps