Database Design – Best Practices for MySQL and Java

databasedatabase-designdesignjavaMySQL

I'm on the way developing an application which requires a kind of dynamic database,

So this is what I want,

enter image description here

This is the for reading the details of a class, the number of variables and methods will only be known at run-time, and I have to create a number of classes like this.

In the above scenario,how can I design a database (MySql) to store all these datas and retrieve them later?

Best Answer

It would be very lengthy to give you a fully normalized db here. Hopefully this would get you started.

tblClasses 
    pk Name
    AnyOtherDataYouwanttostore

tblAttributes
   fk ClassName <-> tblClasses.Name
   Name
   Visibility
   Type ...

tblFunctions
    fk ClassName <-> tblClasses.Name
    Name
    Visibility
    ReturnType ...

Depending on your design, it may be better to use an Identity column for your primary key for tblClasses and then use that for your Foreign Key in the other tables. It all depends on your datatypes and the rest of the data you need to store.

Related Topic