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
Question
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
Solution
The primary and foreign keys in the tables are as follows:
-
Car Table:
- Primary Key: car_VIN
- There is no foreign key in this table.
-
Make Table:
- Primary Key: car_make
- Foreign Key: car_VIN (This is a reference to the car_VIN in the Car table)
-
Model Table:
- Primary Key: car_model
- Foreign Key: car_VIN (This is a reference to the car_VIN in the Car table)
Please note that the design of these tables seems to be flawed. Normally, the car_make and car_model would not be primary keys in their respective tables. Instead, they would be attributes in the Car table, which would have car_VIN as its primary key. The Make and Model tables would then have their own unique identifiers as primary keys, and the Car table would reference these with foreign keys. This would help to eliminate redundancy and improve data integrity and query speed.
Similar Questions
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
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]
Remove the foreign key constraint named fk_driver from the VEHICLES table.
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
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.
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.