Home > database >  How should this table???????
How should this table???????

Time:10-04

A table: drug information (ypid ypname... )
Table B: diagnosis and treatment information (zlid zlname... )
A, B for medical expenses two classification
C table: cost information (time medical number cost classification ypid or zlid... )

Question: C table ypid or zlid display their ypname information, such as how to link? (to determine cost categories, again, can realize this situation? If can not only increase C table field, should be fixed)

CodePudding user response:

In theory A and B table should be C external key table, that is to say, C table should have two fields ypid, zlid respectively with A, B table.

CodePudding user response:

Sorry, said backwards.
In theory should be A table and table B C external key table, that is to say, C table should be two fields ypid, zlid respectively with A, B table.

CodePudding user response:

That said, the estimate is not associated, do you have any other way to provide, thank sdhylj (green front - SS)!

CodePudding user response:

If you can guarantee A table ypid and B table zlid content not repeat, such use can also, but existed shortcomings on the design.

Select A.y pname, c. cost classification, C., c. medical number from A, C where A.y pid=c. cost classification and c. cost classification in (select ypid from A);

Select B.z lname, c. cost classification, C., c. number from B, C where B.z lid=c. cost classification and c. cost classification in (select zlid from B);

CodePudding user response:

To see what you are using the database, I am familiar with oracle, the realization of the oracle SQL to you, realize the main use of decode function
The select... Decode (cost categories, A, ypid, zlid) and decode (cost classification, A, ypname, zlname)
Explain: the decode function is the conditions of the SQL statement, if "cost classification"="A", so ypid, otherwise zlid, other similar, hope to help, if not with oracle database, you can find you using the database of similar function,

CodePudding user response:

Add a field, add a question what problems are solved, but the page could be trouble,

CodePudding user response:

Select A.y pname names as fees, c. cost classification, c. time, c. medical number from A, C where A.y pid=c. cost classification and c. cost classification in (select ypid from A) union select B.z lname names as fees, c. cost classification, c. time, c. number from B, C where B.z lid=c. cost classification and c. cost classification in (select zlid from B);

CodePudding user response:

MS SQL.

CodePudding user response:

Two big strongman

CodePudding user response:

A simple
A, add a record (id, name of the drug, prices) (0, without this, 0)
B up to add a record (id, diagnosis and treatment projects, prices) (0, without this, 0)
Foreign key table contains id_1 c (set association, Anderson d defaut 0)
Foreign key id_2 (set association b.i d, defaut 0)

To do the main table c, do the data window; Can

CodePudding user response:

Can be scattered points

CodePudding user response:

Cost classification must be included in the two tables, it can put the two result sets to do a connection!

Select c., c. number, a.y pnam from a, c where a.y pid=c. cost classification
The union
Select c., c. number, b.z lname from b, c where b.y pid=c. cost classification
So, need not care about ever.

CodePudding user response:

I don't know, to help

CodePudding user response:

The select a.y pname, b.z lname, c. * from a, b, c where a.y pid (+)=c.y pid and b.z lid (+)=c.z lid

CodePudding user response:


Have any PB can master to moonlight as a training instructor? If an interested friends, please send resume

To: [email protected], please contact: QQ: 174629429 MSN:[email protected]

CodePudding user response:

Premise is ypid and zlid cannot have repeated, can use char types, adding character to distinguish, such as: yp00001, zl00001

Select c., c. number, a.y pname as cost
The from c, a,
Where c. Cost classification=a.y pid

The union

Select c., c. number, b.z lname as cost
The from c, b
Where c. cost classification=b.z lid
  • Related