Question: This is regarding SQL or databases. Here I have 2 queries to create 2 tables (part and product). The idea is that a product may

This is regarding SQL or databases.

Here I have 2 queries to create 2 tables (part and product). The idea is that a product may require multiple parts and that it might require more than 1 of a part.

Here are the Queries:

Create Table Part ( Part_id int NOT NULL AUTO_INCREMENT, PartType Varchar(50), PartAmountAvailable int, PartDescription VARCHAR(50), CONSTRAINT Part_id_PK PRIMARY KEY (Part_id) );

Create Table Product ( Product_id int NOT NULL AUTO_INCREMENT, Part_id int, AmountOfPartsNeeded int, ProductType varchar (50), ProductDescription VARCHAR (50), CONSTRAINT Product_id_PK PRIMARY KEY (Product_id), CONSTRAINT Part_id_FK FOREIGN KEY (Part_id) REFERENCES Part(Part_id) );

I'd like to figure out a few things, first of all how do I make more or less Part_id to different Product entities, as in how do i give more or less Part_id to a product.

The second thing I'd like to figure out is how would I link the products and the parts so that certain products may need more than one of a part.

Thanks a bunch.

Here are the queries in picture form

00 1 2 3 4 5 6 CONSTRAINT Part_id_PK PRIMARY KEY (Part_id)

CoursHeroTranscribedText

00 1 2 3 4 5 6 CONSTRAINT Part_id_PK PRIMARY KEY (Part_id) 7 9 10 11 12 13 34 14 FRO Create Table Part ( Part_id int NOT NULL AUTO_INCREMENT, PartType Varchar(50), 15 16 17 18 PartAmountAvailable int, PartDescription VARCHAR(50), ); Limit to 1000 rows Create Table Product ( Product_id int NOT NULL AUTO_INCREMENT, Part_id int, AmountOfParts Needed int, Product Type varchar (50), Product Description VARCHAR (50), CONSTRAINT Product_id_PK PRIMARY KEY (Product_id), CONSTRAINT Part_id_FK FOREIGN KEY (Part_id) REFERENCES Part (Part_id) );

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!