Question
1.Please create related three tables about a subjects (for exp. Students, Employees, Products, Books, Club_Membership, Hobbies etc.) must contain at least a default value definition
1.Please create related three tables about a subjects (for exp. Students, Employees, Products, Books, Club_Membership, Hobbies etc.) must contain at least a default value definition and a primary key, a foreign key,unique,not null and check constraints.
Persons Table -
CREATE TABLE Persons ( ID int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int CHECK (Age>=18), City varchar(255) DEFAULT 'Earth', PRIMARY KEY(ID) );
Orders Table
CREATE TABLE Orders ( OrderID int NOT NULL, PersonID int, PRIMARY KEY (OrderID), FOREIGN KEY (PersonID) REFERENCES Persons(ID) );
Resturants Table -
CREATE TABLE Resturants ( ID int NOT NULL, Name varchar(255) NOT NULL, Order_ID int, FOREIGN KEY (Order_ID) REFERENCES Orders(OrderID), UNIQUE (ID) );
these are the tables and below are the questions;
2. Create a view. (10 points) Write SQL commands below: a.)Create a simple view for each tables.
b.)Create a complex view that joining with three tables.
3.Create a non-unique index on each table for a non-uqiue column. (10 points) Write SQL commands below:
4. Create a sequence for primary key column on each table. (10 points) Write SQL commands below:
5.Insert any three records to each table. (10 points) Write SQL commands below:
6.Update at least one record on each table. (10 points) Write SQL command/s below:
7. Create backup tables from your tables. (10 points) Write SQL command/s below:
8. How to list your objects (tables,views,indexes,sequences,synonyms) and constraints.Please write commands and results. (10 points) Write SQL command/s below:
9. Please add a new column to your tables. Write sql commands and results. (10 points) Write SQL command/s below:
10. Write a conditional insert statement (10 points)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started