How to create 1:N relationship tables?

Asked

Viewed 1,288 times

1

I’ve studied databases and understand how to diagram this type of relation, but now that I’m trying to implement this database using sqlite3 and python I’ve seen some problems. I have the following database Diagrama de BD espectroradiômetros

The problem is that I have the need to create new tables of Esp (U,IV,e Vis) for each of the rows of the Master table. Each row of the Master table has data corresponding to a day of readings from three sensors. These sensors have a data reading of two columns with data corresponding to a graph (Cartesian plane x,y). There would be three tables of pairs x,y (more than a thousand lines) for each of the rows of the master table I can illustrate the relationship as followsDiagrama simplificado Where the red highlight will match the data that must be related.

So my difficulty is in creating the tables, because I can not create two tables with the same name, and then I would have to keep creating the tables Esp with the nomenclature Esp_u1,Esp_u2,Esp_u3...? That doesn’t seem right at all

Please someone tell me what to do about the creation, will be tables with very different names. What would be the correct way to implement the 1:M relationship?

2 answers

1


The problem has been solved. I’ve always had trouble understanding the concept, but IN FACT, when creating a 1:N relationship I’m not creating many tables for a table, I’m just creating more rows in the existing table and numbering a field to tell which "instance" of the table the data belongs to. then I don’t need to create more tables, the concept is to simply add the value in the same table, but refer as if it were another with use of more values in the foreign key.

Whatever sorry for the confusion

0

Guy if you need to create new tables for your data means that your DBMS architecture as a whole is wrong.

Have to review all the data and what you are wanting to do with your application.

Explain to me what your problem is Depending on you need an auxiliary structure a join table. for in cases of M:M

What is this master table?

it gathers data from other tables?

If yes you diagrammed wrong maybe it lacks a structure. or maybe you didn’t understand a simpler thing the table you created manages all the data.

Tables are generally a means of storing information

or be a fruit table can hold all the fruits and not only the green.

  • I’ll try to explain it better, but I think the diagram might be wrong anyway. I’ll edit and insert a better explanation

  • guy says what Voce wanted to explain with your project I can help you assemble the model or show you what’s wrong in the way you’re thinking but I need a help.

  • I think I understood my mistake, after observing it better, in a 1:M relationship I wouldn’t actually be creating multiple tables it’s not?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.