LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
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



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:36 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration