Table below shows the structure of a table named Car. Use it to answer the questions that follow:FieldData TypeCarIDIntegerModelVarChar(20)YearofManufactureDateStatusInteger Write an SQL statement that would perform each of the following: i. Create the table Car with the relevant fields; (3 Marks) ii. Make CarID the primary Key; (2 Marks) iii. Add fields name Make and Price that store 30 characters and numbers respectively. (3 Marks
Question
Table below shows the structure of a table named Car. Use it to answer the questions that follow:FieldData TypeCarIDIntegerModelVarChar(20)YearofManufactureDateStatusInteger Write an SQL statement that would perform each of the following: i. Create the table Car with the relevant fields; (3 Marks) ii. Make CarID the primary Key; (2 Marks) iii. Add fields name Make and Price that store 30 characters and numbers respectively. (3 Marks
Solution
i. To create the table Car with the relevant fields, you would use the following SQL statement:
CREATE TABLE Car (
CarID INT,
Model VARCHAR(20),
YearofManufacture DATE,
Status INT
);
ii. To make CarID the primary key, you would modify the create table statement like this:
CREATE TABLE Car (
CarID INT PRIMARY KEY,
Model VARCHAR(20),
YearofManufacture DATE,
Status INT
);
iii. To add fields named Make and Price that store 30 characters and numbers respectively, you would use the ALTER TABLE statement like this:
ALTER TABLE Car
ADD Make VARCHAR(30),
ADD Price INT;
Similar Questions
Create a table named "products" with columns "product_id" (int), "product_name" (varchar), "description" (varchar), "unit_price" (decimal), and "available_stock" (int). Additionally, the table should have constraints such that "product_id" acts as the primary key and "product_name" is unique.The table structure is given below:Input format :No console input.Output format :The output should display a detailed description of the created 'products' table.Field Type Null Key Default Extraproduct_id int NO PRI NULL product_name varchar(50) YES UNI NULL description varchar(200) YES NULL unit_price decimal(10,2) YES NULL available_stock int YES NULLRefer to the sample output for the column headers.
Create a table named "products" with columns "product_id" (int), "product_name" (varchar), "description" (varchar), "unit_price" (decimal), and "available_stock" (int). Additionally, the table should have constraints such that "product_id" acts as the primary key and "product_name" is unique.The table structure is given below:
You are a database administrator for a car dealership. The company is growing, and the number of cars the company needs to keep track of has increased. The limitations of the current database design have become more noticeable. There is a lot more repeated data, such as car makes, models, and VIN numbers. This redundancy is causing issues with data integrity and making queries slow. In the tables below what are the primary and foreign keys? Car Tablecar_VINMake Tablecar_makecar_VINModel Tablecar_modelcar_VIN
Consider the following table:Product TableColumn NameDataTypeConstraintprod_nameVarchar2(20) prod_idNumber(10)PK Customer TableColumn NameDataTypeConstraintcust_last_nameVarchar2(20) cust_idNumber(10)PKcust_cityVarchar2(20) Sales TableColumn NameDataTypeConstraintprod_idNumber(10)FKcust_idNumber(10)FKquantity_soldNumber(10,2) Generate a report that gives details of the customer's last name, name of the product and the quantity sold for all customers in 'Tokyo'.Which two queries give the required result? (Choose two.)Select one or more:a.SELECT c.cust_last_name,p.prod_name,s.quantity_soldFROM products p JOIN sales sON(p.prod_id=s.prod_id)JOIN customers cON(s.cust_id=c.cust_id)WHERE c.cust_city='Tokyo';b.SELECT c.cust_last_name,p.prod_name,s.quantity_soldFROM products p JOIN sales s JOIN customers cON(p.prod_id=s.prod_id)ON(s.cust_id=c.cust_id)WHERE c.cust_city='Tokyo';c.SELECT c.cust_last_name,p.prod_name,s.quantity_soldFROM sales s JOIN products pUSING (prod_id)JOIN customers cUSING (cust_id)WHERE c.cust_city='Tokyo';d.SELECT c.cust_last_name,p.prod_name,s.quantity_soldFROM products p JOIN sales sUSING (prod_id)ON(p.prod_id=s.prod_id)JOIN customers cUSING(cust_id)WHERE c.cust_city='Tokyo';
Create following table using SQL statements.Client tableField name Data type AttributesClientno char(6) Primary keyName Varchar(20) Not NullCity Varchar(50) Not NullPin NumberMobile Char(10)
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.