File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases 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 and Relational Databases
Bookmark "Some more doubts?" Watch "Some more doubts?" New topic

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.
Tomasz Piasecki

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:
subject: Some more doubts?
It's not a secret anymore!