Re: [PHP-DB] re:database tables relations advice

[email protected] (mrfroasty)
Newsgroups php.db
Message-ID <[email protected]>
maruti wrote:
> hey lemme knoe, how many columns are you planning for?
> y not put table B columns in table A??
> if you are least bothered about data normalizations, simply go the way
> you want to.
> userId  Name Age Age  Sex Occupation Location
> all the data which has correspondence with userid can be put in a
> single table..
> the case is if you dont've many related tables..
> pavan puligandla
> Microsoft has no beef with OpenSource.
>
>
> 2008/11/27 mrfroasty <[email protected] <mailto:[email protected]>>
>
>     maruti wrote:
>     > hii,,
>     > who said table with more no:of columns is a bad database design?
>     > coming to your tables,
>     > what do you wanna do??
>     > if you want to pull out the data of 'X' userid from table B,
>     then you
>     > can use left join.
>     > make sure that user ID of table A and userID of table B have same
>     > data. to use joins, atleast one column(s) should be the same in both
>     > tables.
>     > let me know whether userID of table B is a foreign key of UserID of
>     > table A or not?
>     >
>     > normalization in all cases doesnt work.
>     > i'm using spreadsheet as my front end, so my tables are not even in
>     > the second normal form..
>     >
>     > here are some excellent tutorials for joins;
>     > http://www.tutorialspoint.com/mysql/mysql-using-joins.htm
>     >
>     http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html
>     > hope these might help u alot..
>     >
>     >
>     > pavan puligandla
>     > Microsoft has no beef with OpenSource.
>     >
>     >
>     > 2008/11/27 mrfroasty <[email protected]
>     <mailto:[email protected]> <mailto:[email protected]
>     <mailto:[email protected]>>>
>     >
>     >     I am quite new to database designs, I have a problem in my
>     design...I
>     >     can actually feel it, but I am not quite sure if there is a
>     feature in
>     >     mysql or I have to solve it with programming.
>     >
>     >     Example:
>     >     CREATE TABLE A (
>     >                    user_id int(16) NOT NULL auto_increment,
>     >                    ..........other datas
>     >                    PRIMARY KEY (user_id)
>     >                   );
>     >
>     >     CREATE TABLE B (
>     >                    user_id int(16) NOT NULL auto_increment,
>     >                    ..............other datas
>     >                    PRIMARY KEY (contact_id)
>     >                );
>     >
>     >     Question:
>     >     How can I declare that the user_id in my 1st table is related to
>     >     user_id
>     >     in the 2nd table...actually I prefer to have it exactly the same
>     >     user_id
>     >     in both tables....I think if those 2 entries are the same it
>     will be
>     >     great, but I am not sure how to achieve this.
>     >
>     >     P:S
>     >     -Ofcourse I know that I can extract it from TABLE A and save
>     it in
>     >     TABLE
>     >     B....but is that a way to go???Because this issue arise in
>     couple of
>     >     tables in my data structure that I am tending to use in my
>     >     application(web).
>     >     -I also know that its possible to  make just 1 big table
>     with lots of
>     >     columns....but I read its not a good database design...
>     >
>     >     ----->>>>>please advice, running out of ideas :-(
>     >
>     >     Thanks......
>     >
>     >
>     >     --
>     >     Extra details:
>     >     OSS:Gentoo Linux-2.6.25-r8
>     >     profile:x86
>     >     Hardware:msi geforce 8600GT asus p5k-se
>     >     location:/home/muhsin
>     >     language(s):C/C++,VB,VHDL,bash
>     >     Typo:40WPM
>     >     url:http://mambo-tech.net
>     >
>     >
>     >     --
>     >     PHP Database Mailing List (http://www.php.net/)
>     >     To unsubscribe, visit: http://www.php.net/unsub.php
>     >
>     >
>     Quote:
>     make sure that user ID of table A and userID of table B have same
>     data.
>
>     #That is actually what I am looking for, but I dunno how to achieve
>     that.If I can have those 2 user_id columns with the same data, my
>     problem is technically solved.But as I said earlier I am limited to
>     database skills, its my first application that involves mysql &&
>     php....do I need those foreign key stuffs, to have those 2 columns
>     with
>     the same data??
>
>     --
>     Extra details:
>     OSS:Gentoo Linux-2.6.25-r8
>     profile:x86
>     Hardware:msi geforce 8600GT asus p5k-sehave
>     location:/home/muhsin
>     language(s):C/C++,VB,VHDL,bash
>     Typo:40WPM
>     url:http://mambo-tech.net
>
>

That issue arise like 3 times in my data structure....having all related
data in one table I might ended up with a table of ~20 columns, it will
be too much and probably bad programming practise.....I will have a look
over the net about FOREIGN KEY....didnt know what it is, may be its the
solution...

Thanks for the input....



-- 
Extra details:
OSS:Gentoo Linux-2.6.25-r8
profile:x86
Hardware:msi geforce 8600GT asus p5k-se
location:/home/muhsin
language(s):C/C++,VB,VHDL,bash
Typo:40WPM
url:http://mambo-tech.net
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.