2

Is it a good thing to create a database without relationships between the tables?

Is there any problem doing this? I have to design a database with historical events, sports events, environment data, etc. but can I put them in only one database?

Tim M.
  • 53,671
  • 14
  • 120
  • 163
Mhuz
  • 41
  • 1
  • 5
  • The power of a relational database comes from the relationships between the various tables. You can have discrete subsets of the tables that work together and ignore (are unrelated to) other tables also in the same database — but such a segmented schema could be sensibly stored in separate databases too. The database encapsulates the 'universe of discourse' — it represents what you can ask questions about. With historical events, it is likely that there are multiple tables related to each other. Similarly with the environment data. – Jonathan Leffler Jun 08 '18 at 15:57
  • However, there's a good chance that if the historical events data relates to things that happened 800 years ago and the environment data records the world in the last decade, there is no meaningful overlap between the two sets of tables. – Jonathan Leffler Jun 08 '18 at 15:58
  • Possible duplicate of [Are foreign keys really necessary in a database design?](https://stackoverflow.com/questions/18717/are-foreign-keys-really-necessary-in-a-database-design) – philipxy Jun 09 '18 at 03:28
  • Hi. This is a faq. Please always google many clear, concise & specific versions/phrasings of your question/problem/goal with & without your particular strings/names & read many answers. Add relevant keywords you discover to your searches. If you don't find an answer then post, using use one variant search for your title & keywords for your tags. (You could have googled your first sentence. Also, you can't have thought this was not asked yet.) – philipxy Jun 09 '18 at 03:29

2 Answers2

1

Is a good thing create a database that its table hasn't relationships? Sure if you don't have/need to make relations (Example Table Users and Table StarsInTheSky)

I have to design a database with some historical events, sports events, environment data and other stuff, but can I put them in only one database?

Probably you are talking about putting data in only one table; In my opinion You should think about Normalization: Begin writing in a paper your unique table and the first row (Use your imagination). Question yourself: "Am i repeating some Data in the rows written?"

EX:

Name - Surname - BirthDate - Address

Paul - Allen - 01/11/1957 - 21 Baker Street NY

Paul - Allen - 01/11/1957 - 66 Mullholland Drive LosAngeles

As you can see here U can Relate Personal Data with Address in two distinct table. Question yourself: "Am i using irresponsible Columns (Fields)?

EX:

Name - Surname - BirthDate - Phone1 - Phone2

Paul - Allen - 01/11/1957 - 25412255 - null

What if another user has 3 or 4 phone numbers?

Relate User data with Phone table.

EDIT: Use a single Database or not? AFAIK programs need evolution and implementation in time, maybe one day you would need to make some relation so it's better if u use a single database per Program no matter how many tables u have and if they are related or not, keep the future work as simple as u can :)

Xxx Xxx
  • 143
  • 8
  • Thank you so much for this reply! Nope I'm not talking about putting data in only one table, but having some tables about history, some others about sports, etc, in only one database. Then, if I have a db without relationships between some tables I'll not have performance/security/etc problems, right? – Mhuz Jun 08 '18 at 15:22
  • Sure you can do that, but AFAIK programs need evolution and implementation, maybe one day you would need to make some relation so it's better if u use a single database per Program no matter how many tables u have and if they are related or not :) – Xxx Xxx Jun 08 '18 at 15:47
1

In your case (as you said in a comment, it's for a history table), having no explicit relation between the parent table and the child table isn't a problem, as:

  • you won't need the unique constraints
  • you don't need to delete the orphans (if it's a history table, you want to maintain all the data, isn't it?)

And if the requests to this history table are made independently to the parent (e.g. any ORM used), make sure to have an index in the parent id column to be able to easily retrieve all the data linked to the parent.

Sergio Lema
  • 1,491
  • 1
  • 14
  • 25
  • In that database I have a table with historical events (WWI, WWII, etc). Another table with some sports events (World Championships, etc) and another table with data from arduino sensors – Mhuz Jun 08 '18 at 16:01