hi! i'm trying to builid web catalog and i'm having problems with organizing
my tables. here's what i want:
i have main categories, sub_categories and articles like this:
CATEGORY_1
SUB_CAT_1
Article11
Article12
(...)
SUB_CAT_2
Article24
Article25
(...)
(...)
CATEGORY_2
SUB_CAT_3
Article35
(...)
(...)
(...)
and this is my idea how to do this:
1) first there's table CATEGORIES with "id" and "cat_name"
2) then there's table SUB_CATEGORIES with "id" and "subcat_name"
3) then table ARTICLES with "id", "subcat_id", "article_name" and
"art_price"
4) finally there's table with relations between categories and
sub_categories
like:
relations
id category subcategory
1 1 1
2 1 2
3 2 3
4 2 4
5 2 5
(...)
how i read results:
1) choose category : script outputs category name
2) sql query gets all sub_categories for selected category from table
"relations"
loop
3) output sub_category name
4) select all articles and prices for selected sub_category from
table "Articles"
5) output atricles and prices
till there's no sub_categories left
(sorry for long post)
my question is:
- is there any more elegant and faster way to do this?
thank you all! 7 1703
Personally I'd store a Category ID In the Sub-cat table,
AND a sub-cat id in teh article table. You could probably speed things up by
storing a CatID in the article table too. But it may be overkill. REally
depends on how much pressure the DB server is under. Make sure to set the all
up as indexes.
db
An noise sounding like ToMeK said: hi! i'm trying to builid web catalog and i'm having problems with organizing my tables. here's what i want:
i have main categories, sub_categories and articles like this:
CATEGORY_1 SUB_CAT_1 Article11 Article12 (...) SUB_CAT_2 Article24 Article25 (...) (...) CATEGORY_2 SUB_CAT_3 Article35 (...) (...) (...)
and this is my idea how to do this: 1) first there's table CATEGORIES with "id" and "cat_name" 2) then there's table SUB_CATEGORIES with "id" and "subcat_name" 3) then table ARTICLES with "id", "subcat_id", "article_name" and "art_price" 4) finally there's table with relations between categories and sub_categories like: relations id category subcategory 1 1 1 2 1 2 3 2 3 4 2 4 5 2 5 (...)
how i read results: 1) choose category : script outputs category name 2) sql query gets all sub_categories for selected category from table "relations" loop 3) output sub_category name 4) select all articles and prices for selected sub_category from table "Articles" 5) output atricles and prices till there's no sub_categories left
(sorry for long post)
my question is: - is there any more elegant and faster way to do this?
thank you all!
--
/(bb|[^b]{2})/
Trees with square roots don't have very natural logs.
thanks for reply, first to say i'm very new to databases and php, so i'm
having slight problems following your reply.
what do you mean by:
"Make sure to set the all up as indexes"
tm
"David Gillen" <Be****@RedBrick.DCU.IE> wrote in message
news:sl*******************@carbon.redbrick.dcu.ie. .. Personally I'd store a Category ID In the Sub-cat table, AND a sub-cat id in teh article table. You could probably speed things up
by storing a CatID in the article table too. But it may be overkill. REally depends on how much pressure the DB server is under. Make sure to set the
all up as indexes.
db
An noise sounding like ToMeK said: hi! i'm trying to builid web catalog and i'm having problems with
organizing my tables. here's what i want:
i have main categories, sub_categories and articles like this:
CATEGORY_1 SUB_CAT_1 Article11 Article12 (...) SUB_CAT_2 Article24 Article25 (...) (...) CATEGORY_2 SUB_CAT_3 Article35 (...) (...) (...)
and this is my idea how to do this: 1) first there's table CATEGORIES with "id" and "cat_name" 2) then there's table SUB_CATEGORIES with "id" and "subcat_name" 3) then table ARTICLES with "id", "subcat_id", "article_name" and "art_price" 4) finally there's table with relations between categories and sub_categories like: relations id category subcategory 1 1 1 2 1 2 3 2 3 4 2 4 5 2 5 (...)
how i read results: 1) choose category : script outputs category name 2) sql query gets all sub_categories for selected category from table "relations" loop 3) output sub_category name 4) select all articles and prices for selected sub_category from table "Articles" 5) output atricles and prices till there's no sub_categories left
(sorry for long post)
my question is: - is there any more elegant and faster way to do this?
thank you all!
--
/(bb|[^b]{2})/ Trees with square roots don't have very natural logs.
An noise sounding like ToMeK said: thanks for reply, first to say i'm very new to databases and php, so i'm having slight problems following your reply. what do you mean by: "Make sure to set the all up as indexes"
You've a primary key in your tables, That is an index.
SELECT * FROM BLAH WHERE <PRIMARY_KEY> = 'whatever'
Queries against the primary key will go very quickly, because it is an index.
Similar, if you know you're going to be running lots of queries against
another field which isn't your primary key when doing the create table call
you add in index (<field_name>) near the end. Check the sql reference for you
database and it'll tell you exactly the syntax to use. It'll just speed things
up. Of course, if you set up every field as an index it won't really improve
things. As there is some extra overhead with inserts and updates.
Hope that helps.
D. "David Gillen" <Be****@RedBrick.DCU.IE> wrote in message news:sl*******************@carbon.redbrick.dcu.ie. .. Personally I'd store a Category ID In the Sub-cat table, AND a sub-cat id in teh article table. You could probably speed things up by storing a CatID in the article table too. But it may be overkill. REally depends on how much pressure the DB server is under. Make sure to set the all up as indexes.
db
An noise sounding like ToMeK said: > hi! i'm trying to builid web catalog and i'm having problems with organizing > my tables. here's what i want: > > i have main categories, sub_categories and articles like this: > > CATEGORY_1 > SUB_CAT_1 > Article11 > Article12 > (...) > SUB_CAT_2 > Article24 > Article25 > (...) > (...) > CATEGORY_2 > SUB_CAT_3 > Article35 > (...) > (...) > (...) > > and this is my idea how to do this: > 1) first there's table CATEGORIES with "id" and "cat_name" > 2) then there's table SUB_CATEGORIES with "id" and "subcat_name" > 3) then table ARTICLES with "id", "subcat_id", "article_name" and > "art_price" > 4) finally there's table with relations between categories and > sub_categories > like: > relations > id category subcategory > 1 1 1 > 2 1 2 > 3 2 3 > 4 2 4 > 5 2 5 > (...) > > how i read results: > 1) choose category : script outputs category name > 2) sql query gets all sub_categories for selected category from table > "relations" > loop > 3) output sub_category name > 4) select all articles and prices for selected sub_category from > table "Articles" > 5) output atricles and prices > till there's no sub_categories left > > (sorry for long post) > > my question is: > - is there any more elegant and faster way to do this? > > thank you all! > >
--
/(bb|[^b]{2})/ Trees with square roots don't have very natural logs.
--
/(bb|[^b]{2})/
Trees with square roots don't have very natural logs.
ToMeK wrote: i'm trying to builid web catalog and i'm having problems with organizing my tables. here's what i want:
i have main categories, sub_categories and articles like this:
CATEGORY_1 SUB_CAT_1 Article11 Article12 (...) SUB_CAT_2 Article24 Article25 (...) (...) CATEGORY_2 SUB_CAT_3 Article35 (...) (...) (...)
and this is my idea how to do this: 1) first there's table CATEGORIES with "id" and "cat_name" 2) then there's table SUB_CATEGORIES with "id" and "subcat_name" 3) then table ARTICLES with "id", "subcat_id", "article_name" and "art_price" 4) finally there's table with relations between categories and sub_categories
Number 4, I think, is completely unnecessary. Instead, consider
adding a `cat_id` field to the `SUB_CATEGORIES` table.
Also, be sure the following fields are indexed:
CATEGORIES.id
SUB_CATEGORIES.id
SUB_CATEGORIES.cat_id (if you choose to have it, that is)
ARTICLES.id
ARTICLES.subcat_id
Cheers,
NC
Hi,
maybe this helps. You're trying to embed what are really arbitrary
indexes into the structure of your tables containing your data. Why
can't you have a flat table of articles with IDs, and then build
category indexes independently on other tables, whatever structure
they may take in the future.
Articles on futility of modeling: http://www.bkent.net/Doc/limrec.htm http://www.bkent.net/Doc/brinmod.htm
Try to avoid foreign keys in the tables containing the basic data
(entities).
HTH
I noticed that Message-ID:
<11**********************@f14g2000cwb.googlegroups .com> from gu******@yahoo.com contained the following: You're trying to embed what are really arbitrary indexes into the structure of your tables containing your data. Why can't you have a flat table of articles with IDs, and then build category indexes independently on other tables, whatever structure they may take in the future.
<snip> Try to avoid foreign keys in the tables containing the basic data (entities).
Absolutely. An entity relationship diagram would help. To determine
the required number of tables the OP needs to know the relationship
between the entities. For instance one sub category can contain many
articles but can one article appear in many sub categories? If the
answer is yes, the OP has a many to many relationship and a link table
is required.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
I assumed that an article can appear in many categories. But I'd go as
far as creating a link table for every relation, even if one-to-one.
I really don't like foreign keys in data tables. ER diagrams are nice
in the abstract, but might lead to more complexity, or make you think
you have an inheritance hierarchy or network or small world or
whatever, when you really only want two layers of tables. The upper
layer is a straight line of tables representing relations, groups,
structures, categories, indexes, inheritance, what have you, the
bottom layer is a straight line of data tables without foreign keys. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: GBartgo |
last post by:
Hi everybody,
I don't know how to initialize the weight vector of each node in the tree.
The input is a set of N data in M dimensions.
I have to realize a software based on the article "S-TREE:...
|
by: Jamie |
last post by:
Hi,
Thanks for the excellent answer to my last question! One more:
Does anyone have a method they follow for organizing stylesheets
themselves? They seem like they can get bloated and hard to...
|
by: Andrea |
last post by:
Hi All,
I am looking for SOM running under WIN32 and Microsoft Visual Studio 6.0.
Can anybody help me?
Andrea
p.s. I apologize for cross-posting, but I have to solve this problem quickly
:|
|
by: Rada Chirkova |
last post by:
Hi,
at NC State University, my students and I are working on a project called
"self-organizing databases," please see description below. I would like to
use an open-source database system for...
|
by: netsurfer802 |
last post by:
I have a question regarding working with seperate files and organizing
these files. The company I'm working for is a small comuter company
that calls people that have went to computer trade...
|
by: Tarscher |
last post by:
Hi all,
I 'm building a website that provide services for soccer teams. When a
user (team) signs up I want to give him some personal space like
http://www.soccerteamonline.com/teamname where...
|
by: Ushach |
last post by:
hi,
I want to know about Self Organizing maps.T ounderstand the concept ,I need a small example which explains how clustering is done through self organizing maps?If any body implemented it plz...
|
by: jehugaleahsa |
last post by:
Hello:
I have a bunch of related items that are either parents, children or
not directly related to each other. In my case, I have a bunch of
database tables joined with foreign keys. Another...
|
by: Desitech |
last post by:
I am getting ready to build a new Database for a Golf Tournament I have each year. I am having trouble organizing how I want to build my tables. I have many golfers that golf each year but usually...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |