aspose file tools*
The moose likes JDBC and the fly likes Some more doubts? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Some more doubts?" Watch "Some more doubts?" New topic
Author

Some more doubts?

Sajee Joseph
Ranch Hand

Joined: Jan 17, 2001
Posts: 200
Hi all,
I have a few doubts in mind
1. Is there any flaw if i have a table with no primary keys ? I mean, am i risking the quality of my design, doing so?
2. Suppose i have a table TableA with 3 fields, a, b, c. Suppose a and b are the combinational keys. Consider these rows of TableA
1,1, Gen
1,2, Mr
1,3, Mrs
1,4, Fr
......
Suppose i run a query to get me all c's where a = 1, then will i always get them in the order Gen, Mr, Mrs, Fr.?
What r the rules that govern the order in which i get the result rows.
Regards
Saj
Tomasz Piasecki
Greenhorn

Joined: Dec 14, 2001
Posts: 9
Re: Q1.: It all depends on the DataBase type you are using if it is Oracle 8-up, then, as far as I know, you must declare PK and FK otherwise you will receive errors when creating tables.
If you use mySQL I read some toutorials that did not specify any keys whatsoever, and it was working fine. However I've been tought that a good database design always requires declaring PK and FK. If you do not specify them it is a performance issue of finding data in your database. If the database is fairly small there shouldn't be a problem, but if you have to manage huge database then... lots of trouble.
Q2. If you don't do "order by" in your SQL query then you will get the data as is. (SEE: O'Reilley SQL*Plus reference for use of: "group by" and "order by").
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Some more doubts?