For part a, if I delete model 200007 in laptop, would it also affect other table
ID: 3576446 • Letter: F
Question
For part a, if I delete model 200007 in laptop, would it also affect other tables with model 200007?
Consider the following relational Schema and corresponding sample data: Product (model, type, maker) (model, name, price) Distributor (model, speed, ram, hd) PC Laptop model, speed, ram, hd, screen, (model, color, type) Printer The keys are underlined. Distributor model, PC model, Laptop. model, and Printer. model are all foreign keys to Product. model. Referential integrity constraints are enforced through CASCADE for DELETE and SET NULL for UPDATE, respectively. model speed had Tam, 3.2 100001 32 4096 100002 2.1 16 1024 model maker model type name price 100003 3.2 32 8192 P1 100001 D3 100001 680 pc 100004 2.7 64 8192 100002 pc P2 100002 D3 630 100005 2.5 32 4096 100003 pc P2 100004 D3 780 100006 2.2 16 4096 100004 pc P3 100005 D3 550 100005 pc P1 200003 D1 1000 model speed ram had 100006 pc P2 2000003 D2 800 Screen 200001 laptop P4 20000003 D3 980 3.2 200001 165 4096 15 200002 laptop P5 20000004 P3 680 200002 2.1 16 1024 13 2000003 laptop P1 200008 P3 880 200003 3.2 32 512 17 2000004 laptop P3 20000009 P3 620 200004 2.7 256 15 2000005 laptop P3 2000010 D1 540 2000005 2.5 8 4096 15 2000006 laptop P2 200000010 D2 570 200006 2.2 16 4096 17 2000007 laptop P4 2000007 P3 930 200007 2.2 8 2048 17 200008 laptop P1 2000007 P2 890 200008 3.2 32 4096 13 2000009 laptop P1 20000004 D3 680 2000009 2.8 8 2048 15 200010 laptop P1 200004 P1 580 2000010 3.2 32 512 13 300001 printer P6 200004 P2 640 300002 printer P6 30000004 D3 180 model color type 3000003 printer P2 3000002 D1 280 300001 T laser 3000004 printer P3 3000002 D3 200 300002 T laser 300005 printer P3 300000001 P3 80 3000003 F ink-jet 3000004 F laser 3000005 F laserExplanation / Answer
No, if you delete model 200007 in laptop table it will not affect in other tables because laptop table is a child table to the product table.I.e. product.model is the primary key and laptop.model is the foreign key which is referencing to the primary key. So, if you have deleted model 200007 from laptop it will be deleted in laptop only and nothing will be change in other tables.
If you want to delete the data from one table and this needs to be updated in other tables which are referencing to that table,if that is the case you have to delete from the parent table that is the table which are referencing by all other tables.
In this case the primary key is product.model which means it is the parent table and all the other which are having foreign keys and referencing to product table those all are the child keys.So, if you delete from the procut table it will affects to all other tables the other sie is not possible. Even though you can delete data from the child tables those will be not affected to any other table.
And an important note is :- When only if you have used DELETE CASCADE to the table definition on the child table referencing to some other table called parent, then only it is possible that parent table changes will effect to all child tables otherwise none will be changed.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.