dbTalk Databases Forums  

Imperial dimension

comp.databases comp.databases


Discuss Imperial dimension in the comp.databases forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
cronept@msn.com
 
Posts: n/a

Default Imperial dimension - 08-01-2003 , 12:59 PM






Hi,

I am working on an elevator order system which is going to show many
dimensions on a form. I have to show all dimensions in Arch Dimension
style, i.e.: 7'-8 3/8" instead of using inches only. I think if
seperating one dimesion filed to 3 fileds(1st: foot; 2nd: inch; 3rd:
fraction), I may able to solve it. But since I have so many
dimensions, I prefer to use one field. But then comes out many
problems:
1. This field has to be a text field, not a number filed.We need to
use all data from this databse to creat parametric drawings. Text is
not recognized by the drawing software.

2. How to add constraints to the filed: i.e.: 7'-8" is correct, can't
be 7'-13".

Is this possible? Or there's other solution for this problem? Please
help me. Thank you very mcuh.

Jin

Reply With Quote
  #2  
Old   
Christopher Browne
 
Posts: n/a

Default Re: Imperial dimension - 08-01-2003 , 03:53 PM






Centuries ago, Nostradamus foresaw when cronept (AT) msn (DOT) com (cronept (AT) msn (DOT) com) would write:
Quote:
I am working on an elevator order system which is going to show many
dimensions on a form. I have to show all dimensions in Arch Dimension
style, i.e.: 7'-8 3/8" instead of using inches only. I think if
seperating one dimesion filed to 3 fileds(1st: foot; 2nd: inch; 3rd:
fraction), I may able to solve it. But since I have so many
dimensions, I prefer to use one field. But then comes out many
problems:
1. This field has to be a text field, not a number filed.We need to
use all data from this databse to creat parametric drawings. Text is
not recognized by the drawing software.

2. How to add constraints to the filed: i.e.: 7'-8" is correct, can't
be 7'-13".

Is this possible? Or there's other solution for this problem? Please
help me. Thank you very mcuh.
In PostgreSQL, you could implement your own type for this. (See
"CREATE TYPE" for documentation on this.)

Recent versions of Informix, being based on the related Illustra code
base, allow creation of "Data Blades" that exist for the same purpose.

Alternatively, you might use a rational data type to express the data,
and write a pair of functions that translate back and forth between
text and the database representation. This approach should be usable
with any DBMS supporting stored procedures and functions.

select name, dim_to_text(length) as length, dim_to_text(height) from
some_table;

or

insert into some_table (name, length, height)
values ('Blue Grapple Grommet', text_to_dim('7''-8"'),
text_to_dim('9''-7"'));

where text_to_dim() raises exceptions if given invalid dimensions...
--
"cbbrowne","@","cbbrowne.com"
http://www3.sympatico.ca/cbbrowne/linux.html
Rules of the Evil Overlord #11. "I will be secure in my
superiority. Therefore, I will feel no need to prove it by leaving
clues in the form of riddles or leaving my weaker enemies alive to
show they pose no threat." <http://www.eviloverlord.com/>


Reply With Quote
  #3  
Old   
programmer
 
Posts: n/a

Default Re: Imperial dimension - 08-04-2003 , 05:37 AM



Quote:
I am working on an elevator order system which is going to show many
dimensions on a form. I have to show all dimensions in Arch Dimension
style, i.e.: 7'-8 3/8" instead of using inches only. I think if
seperating one dimesion filed to 3 fileds(1st: foot; 2nd: inch; 3rd:
fraction), I may able to solve it. But since I have so many
dimensions, I prefer to use one field. But then comes out many
problems:

Store the size as an integer representing 64ths of an inch. Then you can
create a view giving feet, inches and 64ths. You might have to use some code
to reduce and display the fraction - eg 32/64 --> 1/2


create table sizes(id int, f_64ths int);

insert into sizes values (1, 1057);

insert into sizes values (2, 5483);

insert into sizes values (3, 109);

insert into sizes values (4, 1928);

insert into sizes values (5, 31);


drop view size_frac

create view size_frac as
select id, f_64ths,
floor(f_64ths/64/12) as ft,
floor(f_64ths/64) - floor(f_64ths/64/12) * 12 as inch,
f_64ths - floor(f_64ths / 64) * 64 as sixtyfourths
from sizes;

select * from size_frac;


ID F_64THS FT INCH SIXTYFOURTHS
1 1057 1 4 33
2 5483 7 1 43
3 109 0 1 45
4 1928 2 6 8
5 31 0 0 31






Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.