- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Does MySQL support table inheritance?
MySQL uses foreign key constraint instead of inheritance. MySQL does not support table inheritance.
You can achieve the same with the help of foreign key constraint. Let us create a table and use the foreign key constraint. The query to create the first table is as follows −
mysql> create table Parent_Table -> ( -> ParentId int, -> PRIMARY KEY(ParentId) -> ); Query OK, 0 rows affected (3.59 sec)
Now create the second table. The query to create the second table is as follows −
mysql> create table Child_Table -> ( -> ChildId int references Parent_Table, -> PRIMARY KEY(ChildId) -> ); Query OK, 0 rows affected (0.73 sec)
Now add the foreign key relationship between two tables. The query is as follows −
mysql> alter table Child_Table add constraint FK_Child Foreign key(ChildId) references Parent_Table(ParentId); Query OK, 0 rows affected (2.28 sec) Records: 0 Duplicates: 0 Warnings: 0
- Does java support hybrid inheritance?
- Does Python support multiple inheritance?
- Does Java support multiple inheritance? Why? How can we resolve this?
- Does Python support polymorphism?
- Does Selenium support Safari browser?
- How does Inheritance work in Ruby?
- Does HTML5 Canvas support Double Buffering?
- Does C++ support Variable Length Arrays
- Does Java support multi-dimensional Arrays?
- Does Selenium support headless browser testing?
- What information does SHOW TABLE DOES display in MySQL
- How does class inheritance work in Python?
- What type of comments does C++ support?
- Does cypress support api automation testing also?