Consider the relation Database.Person(SSN, name, city)Car(license_no, year, model, SSN)Accident(drive_no, SSN, license_no, accidentyear, damage_amt)1) Find the name of driver who did not have an accident in 'Delhi'.2) Find the cars sold in 2006 and whose owner are from vadodara.3) How many different models of car are used by Mr.abc
Question
Consider the relation Database.Person(SSN, name, city)Car(license_no, year, model, SSN)Accident(drive_no, SSN, license_no, accidentyear, damage_amt)1) Find the name of driver who did not have an accident in 'Delhi'.2) Find the cars sold in 2006 and whose owner are from vadodara.3) How many different models of car are used by Mr.abc
Solution
- To find the name of the driver who did not have an accident in 'Delhi', you would first need to identify the drivers who had an accident in 'Delhi'. This can be done by joining the 'Person' and 'Accident' tables on the 'SSN' field and filtering for accidents in 'Delhi'. Then, you would need to select the drivers from the 'Person' table who are not in the list of drivers who had an accident in 'Delhi'.
Here is the SQL query for this:
SELECT name
FROM Database.Person
WHERE SSN NOT IN (
SELECT SSN
FROM Database.Accident
JOIN Database.Person ON Database.Accident.SSN = Database.Person.SSN
WHERE city = 'Delhi'
)
- To find the cars sold in 2006 and whose owners are from Vadodara, you would need to join the 'Person' and 'Car' tables on the 'SSN' field and filter for cars sold in 2006 and persons from Vadodara.
Here is the SQL query for this:
SELECT license_no, year, model
FROM Database.Car
JOIN Database.Person ON Database.Car.SSN = Database.Person.SSN
WHERE year = 2006 AND city = 'Vadodara'
- To find out how many different models of car are used by Mr.abc, you would need to join the 'Person' and 'Car' tables on the 'SSN' field and filter for the person named 'Mr.abc'. Then, you would need to count the distinct models of cars.
Here is the SQL query for this:
SELECT COUNT(DISTINCT model)
FROM Database.Car
JOIN Database.Person ON Database.Car.SSN = Database.Person.SSN
WHERE name = 'Mr.abc'
Similar Questions
Person(SSN, name, city)Car(license_no, year, model, SSN)Accident(drive_no, SSN, license_no, accidentyear, damage_amt)1) Find the name of driver who did not have an accident in 'Delhi'.2) Find the cars sold in 2006 and whose owner are from vadodara.3) How many different models of car are used by Mr.abc
Question 10You 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?
Alexander is developing a ride-sharing application to track drivers, vehicles, and trips. The system needs to handle three main types of data: DRIVERS, VEHICLES, and TRIPS. Write the DDL statements to create the following tables with the mentioned constraints to handle the data: The DRIVERS table has a named primary key constraint pk_driver.The VEHICLES table has a named primary key constraint pk_vehicle for VehicleID and a named foreign key constraint fk_driver for DriverID.The TRIPS table has a named primary key constraint pk_trip for TripID and a named foreign key constraint fk_vehicle for VehicleID.symbol refers to the primary key NN refers to Not NULLAlexander ensures the following constraints are altered:Remove the foreign key constraint named fk_driver from the VEHICLES table.Note: The user must write only the query to create and alter the table. The query to display the description of the table is already given.Input format :No console inputOutput format :The output displays the successful table creation status, the structure of all three tables, and the existing foreign key constraint details.Refer to the sample output.Sample test cases :Input 1 :Output 1 :Table DRIVERS created.Table VEHICLES created.Table TRIPS created.Table VEHICLES altered. Name Null? Type ________________ ___________ ________________ DRIVERID NOT NULL NUMBER NAME NOT NULL VARCHAR2(100) LICENSENUMBER NOT NULL VARCHAR2(20) Name Null? Type ____________ ___________ _______________ VEHICLEID NOT NULL NUMBER DRIVERID NOT NULL NUMBER MAKE NOT NULL VARCHAR2(50) MODEL NOT NULL VARCHAR2(50) Name Null? Type ____________ ___________ _________ TRIPID NOT NULL NUMBER VEHICLEID NOT NULL NUMBER TRIPDATE NOT NULL DATE DISTANCE NOT NULL NUMBER TABLE_NAME FOREIGN_KEY_NAME FOREIGN_KEY_COLUMN REFERENCED_CONSTRAINT_NAME REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME _____________ ___________________ _____________________ _____________________________ ________________________ _________________________ TRIPS FK_VEHICLE VEHICLEID PK_VEHICLE VEHICLES VEHICLEID 1 row selected. Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.
onsider the following relations to answer Question.Manufacturer (ManufacturerId, MName, DateOfBirth, Gender MAddress, AwardWon)Part (PartNo, PName, Description, ManufacturerId)Order (PartNo, OrderNo, OrderQuantity, OrderedDate, CustomerId)Customer (CustomerId, Email, CName, CAddress, Job, TotalNoOfCustomers)Most suitable data type (s) for OrderNo, OrderQuantity, OrderedDate in Order relation respectively is/are:Select one:a.Number, Number, Dateb.Text, Text, Datec.Number, Number, Numberd.Number, Text, Datee.Text, Text, Text
CD Motors is a second-hand car dealership. They keep records of all the cars on their forecourt including those that have been bought and sold in a relational database.A sample of a table called 'Cars' from the database is shown.The cars table includes Car Reg, Make, Model, Engine, Type, Year, Doors and Miles. Three cars are shown with the data: VN67 VWS, Volkswagen, Up!, 1.0, Petrol, 2017, 5, 29000 FH15 HVM, Vauxhall, Corsa, 1.3, Petrol, 2015, 5, 15600 VK13 DMX, Kia, Sportage, 1.7, Petrol, 2013, 5, 19200Write a SQL statement that will return the registration for all cars manufactured after the year 2016.[3]
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.