Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-21-2011, 01:30 PM   #1
Registered: Apr 2009
Location: El Salvador
Distribution: Slackware -current
Posts: 166

Rep: Reputation: 17
Database and relationships?

I'm sorry this isn't a question about programming, but i didn't where else to put it, you need to know this up front: i suck at databases, my true love is programming.
ok, so i am about to ask a really noob question:
what goes first?
- create tables, relationships and then insert data? or
- create tables, insert data and then create relationships?

see? the questions sound stupid even to me

anyway i hope you guys can help me. and yeah i will try to get better in databases design and all that.
Old 10-22-2011, 03:20 AM   #2
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 855

Rep: Reputation: 203Reputation: 203Reputation: 203
No 1 is clearly better.

Consider an analogy to the builder of the house.

If relationships are like doors that properly connect rooms (tables), then it is clear that a builder (or architect) should have thought about and built the relationships before building the house. In the absence of such pre-planned relationships, there is the real danger of missing vital relationships and providing unwanted relationships which will only restrict the flow.

Overall, a plan for the realisation stage of the data base (before actual programming) should include relationships.


Some implementors will tell you that building relationships will slow down the one time data insertion but this stems from lack of clarity.

It isn't too difficult.

Sure, nobody is 100% perfect. You can certainly add or change the relationships. But there must be a serious effort to make a plan with relationships before embarking on the insertion process.


Last edited by AnanthaP; 10-22-2011 at 03:21 AM. Reason: Spelling
Old 10-22-2011, 05:17 AM   #3
Senior Member
Registered: Dec 2002
Location: England
Distribution: Used to use Mandrake/Mandriva
Posts: 2,794

Rep: Reputation: 116Reputation: 116
IF you're just trying to collect the data atm, with no hard rules about how it should relate & be consistent, then you'd get away with doing tables -> data -> relationships.
But you'll probably quite easily create something un-normalised with plenty of redundancy, and why use a RDBMS at this stage if you don't have the relations, use another storage system/format/medium.

If you have any existing ideas about how things will be used, what constrains should exist (uniqueness, nulls, foreign keys, value limits, etc), then you're almost certainly better off thinking through the relationships, ensuring all the queries you'll want to run can be created (perhaps also checking efficiency, with test data), before you put your real data into the DBMS rather than having to version/take many backups while you massage it to accept new constraints or table reconstruction without relation mistakes or data loss/distortion.


data, databases, design

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Relationships James97 General 7 07-06-2011 05:31 PM
[SOLVED] question regarding software relationships mrmnemo Linux - Software 4 10-09-2010 10:25 PM
mysql relationships question czarherr Programming 2 03-04-2005 01:57 AM
MySQL Relationships Question? RecoilUK Linux - General 1 08-02-2001 07:05 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:30 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration