Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Have you tried to identify all of the entities and their relationships here? – FrustratedWithFormsDesigner Nov 24 '11 at 5:07
@FrustratedWithFormsDesigner the relationship between the classes?? I do it separately, and for that I need the datas, and thats the reason I need to store all these in a db. – COD3BOY Nov 24 '11 at 5:11
up vote 5 down vote accepted

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

    pk Name

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

    fk ClassName <-> tblClasses.Name
    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.

share|improve this answer
This works nicely, But use an ID field, not name, as the PK in the class table (and of course the FK in the other tables). – Morons Nov 24 '11 at 11:35

You may want to look into MongoDB. Its significantly different than MySQL as it is in the NoSQL group but seems like it might be a good fit for what you need. You can store the dynamic aspects in one table in an array which is something you can't do in a MySQL setup. If however you need/want to stick with the MySQL database then the appropriate method is to split the data between tables as suggested by Jonathan Henson.

FYI the MongoDB Structure would be something like the following:

  Name : NameValue,
  Attributes : {
      0 : {
        AttName : AttNameValue0,
        AttVisibility : AttVisibilityValue0,
        AttType : AttTypeValue0
      1 : {
        AttName : AttNameValue1,
        AttVisibility : AttVisibilityValue1,
        AttType : AttTypeValue1
      2 : ...
  Functions: {
      0 : {
        FuncName : FuncNameValue0,
        FuncVisibility : FuncVisibilityValue0,
        FuncReturnType : FuncReturnTypeValue0
      1 : {
        FuncName : FuncNameValue1,
        FuncVisibility : FuncVisibilityValue1,
        FuncReturnType : FuncReturnTypeValue1
      2 : ...
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.