• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 167
  • Last Modified:

Working with DBGIRD

Hi experts,
I was created a database that store the article fields or ….
This article(entity) has a field that has more than one value(I called keyword).
The relation between  article and keyword(in my idea) is m:n .
Finally , I design two tables, one article and other, keywords as below;
1-     article(ID, title,descript,index,abstract).  ID= primary key
2-     keywords (id,keyword). ID+keyword=primary key , ID=forign key
do any work that implement these two tables with one dbgird that show the real field of article and another field
( example keywords) when user click on this field the values of the field will show(the delete,add and modify available for values) ?


thanks a lot
hamid reza

0
123456
Asked:
123456
  • 5
  • 3
  • 2
  • +1
1 Solution
 
keashFCommented:
you can make a lookup for this. here's how to do it:
* double click on your article Table component (not the DBGrid)
* you'll get a small window where you can add fields you wish to show
* right click and add the fields7
* now it's getting intersting: right click again and choose "new field"
* choose the datatype and name (propably string and "keyword") and select "lookup" for field type.
* using the rest of the comboboxes you can link your table to the keywords table using id, like this:
keyfield=id, datadset=your_keyword_sdataset, lookupkeys=id,
result=keywords

cu
keashF
0
 
BrckoCommented:
exactly the relation is 1:n

for editing you must use master detail view. there are few dbgrid components, that can do this, but they aren't free
(b.e. Quantum Grid)

From my point of view, with standard dbgrid you can't do this (of course, you can do everything, but not easily)
0
 
123456Author Commented:
bracko,
may be one keyword exist in more than one article ( for it M:N);

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
123456Author Commented:
keashf,
I do your comment but I don’t modify, delete & add values.
pay attention to my question  again
do any work that implement these two tables with one dbgird that show the real field of article and another field
( example keywords) when user click on this field the values of the field will show(pay attentionà the delete,add and modify available for values) ?

regards
hamid reza
0
 
keashFCommented:
then i don't understand your question, i'm sorry
0
 
BrckoCommented:
not,
I'm right
for every record in keywords exist exactly one record in articles (ID is foreign key)
a keyword can be in more articles, but it is not same record in table keywords

thus this is relation 1:n

for relation m:n should diagram be

table article
article_id,name,text,...

table keyword
keyword_id,keyword

table article_keyword
article_id (foreign key to articles)
keyword_id (foreign key to keywords)

that means for every article exists 0..n keywords
and every keyword is in 0..n articles

but not about that was question.

to your question, as I wrote upper
it is not possible in ONE simple DBgrid (like shipped with Delphi) display or (work with) master-detail (1:n,m:n) relationship
but try look at Quantum Grid from DevExpress, that component had ability for displaying, editing, ... master-detail records
0
 
123456Author Commented:
I don’t accept your idea,
Why?
because keyword not a independence entity .
In my idea one article can has more than one keyword and a keyword can use in more than one article.
For it,I  restricted more than one field for primary key in keyword table(id+keyword).
Im my idea the relationship is m:n .
Because I don’t accept the keyword as individul entity, I don’t restricted any indepent table for it.
That you say in your example about m:n.

But about quantum grid component ,is this component is free?
 I find a QgridFeaturesDemo.exe  file in my computer ,but I think it s for advertising.
Can I use of this file in my project!?

Regards
Hamid reza

0
 
123456Author Commented:
I don’t accept your idea,
Why?
because keyword not a independence entity .
In my idea one article can has more than one keyword and a keyword can use in more than one article.
For it,I  restricted more than one field for primary key in keyword table(id+keyword).
Im my idea the relationship is m:n .
Because I don’t accept the keyword as individul entity, I don’t restricted any indepent table for it.
That you say in your example about m:n.

But about quantum grid component ,is this component is free?
 I find a QgridFeaturesDemo.exe  file in my computer ,but I think it s for advertising.
Can I use of this file in my project!?

Regards
Hamid reza

0
 
BrckoCommented:
in your system keyword is not usable in more than one article coz every record from keywords has ID which is foreign key into articles

you got 2 fields in primary key of table keywords
article id,keyword
only thing, that this is for is that you can't have two same keywords in one article

your data are
tbl article
============================
id,name,text
============================
1,name1,text 1 with key_word
2,name2,text 2 with key_word

tbl keywords
==========
id,keyword
==========
1,key_word
2,key_word

Am I right?

in my example I showed, what is m:n relationship.

Ok, I'm ending with this discussion, coz it doesn't solve your problem, and only turns into flamewar.

Quantum grid is not free nor cheap, but I don't know free replacement with fetures like this component have.

BTW:
If I had to solve that problem, maybe I have to define
keywords varchar(x) into articles and this looks like this
keyword1;keyword2;keyword3
In my point of view, your system is complicated, and hasn't advantages over mine.
0
 
123456Author Commented:
hi,At first
Some text that you describe in your example about M:N,
1=table article:  article_id,name,text,...

2=table keyword:  keyword_id,keyword

3=table article_keyword:  article_id (foreign key to articles)  keyword_id (foreign key to keywords)

that means for every article exists 0..n keywords( I agree this for my database)
and every keyword is in 0..n articles( I agree this for my database)
fine, every keyword in table_keyword basically is a id(pay attention to mean of keyword),  yes or no ?
if yes I suppose  that this table(table_keyword)  in not necessary, is this true or false?
Finally, I defined a table that mix of two tables one table_article and other table_keyword(that not necessary)
And the result is article_keyword. That give a foreign key from article and table_keyword(that not necessary),
And I bring it(article_keyword) as keywords  table in my database.
We say the same thing but I don’t accept the keyword_table(2) as individual table.

Best Regards
Hamid reza
0
 
moduloCommented:
Dear expert(s),

A request has been made to close this Q in CS:
http://www.experts-exchange.com/Community_Support/CleanUp/Q_20564704.html

Without a response in 72 hrs, a moderator will finalize this question by:

 - Saving this Q as a PAQ and refunding the points to the questionner

When you agree or disagree, please add a comment here.

Thank you.

modulo

Community Support Moderator
Experts Exchange
0
 
moduloCommented:
Saving this Q as a PAQ and refunding the 50 points to the questionner

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 5
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now