LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 10-21-2011, 12:30 PM   #1
michaelinux
Member
 
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, 02:20 AM   #2
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 606

Rep: Reputation: 127Reputation: 127
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.

CERTAINLY BEFORE DATA INSERTION, THE RELATIONSHIPS SHOULD BE IN PLACE.

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.

OK

Last edited by AnanthaP; 10-22-2011 at 02:21 AM. Reason: Spelling
 
Old 10-22-2011, 04:17 AM   #3
Proud
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.
 
  


Reply

Tags
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 04:31 PM
[SOLVED] question regarding software relationships mrmnemo Linux - Software 4 10-09-2010 09:25 PM
mysql relationships question czarherr Programming 2 03-04-2005 12:57 AM
MySQL Relationships Question? RecoilUK Linux - General 1 08-02-2001 06:05 PM


All times are GMT -5. The time now is 08:03 PM.

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