I am developing a taxonomy system (tags, categories, and attributes) with Laravel. Currently in my database I have the following tables, "terms", "term_relationships" and "products". The "term_relationships" table being the pivot table. However, with multiple taxonomies (e.g. categories, tags and attributes), how can I store the taxonomy names without getting them confused between categories, tags or attributes. I see that WordPress uses a 4th table named "term_taxonomy", however I am unsure of how the 4 tables relate to each other.
Would someone be so kind as to enlighten me on this subject providing the best solution to implement such a taxonomy system.
Thank you.
If this can help, I created this package : https://github.com/codiiv/laravel-taxonomies and it's based on the 3 table structure in Wrordpress, but I combined them into one table rather!
Related
I have a categories and users table. A user can have many categories and a category can have many users (many to many). However, I also need a feature were users can insert/create their own categories and which is only accessible to the user (category creator) + the defaults categories.
I created a pivot table to handle the many to many relationship, however, I was having difficulty deciding if I need to create another table to handle the custom user categories or just add a user_id on the categories table.
What would be the correct structure I should take/create to handle this.
Thanks.
Given the information you have described, there are two solutions which would be valid: one would be to have a separate table for custom categories, and my preferred solution, would be to have a boolean value on the categories table which indicates whether a category is custom or not. This gives you the following advantages:
Logic applied to the two similar kinds of category remains the same
Other fields which are shared can be kept, in kind
If you wish to convert a custom category to a real category, this then becomes trivial (change the boolean)
You could include a creator id field to identify the person to whom the category applies, alternatively, you might simply designate in-code that custom categories may only have one member.
I have a working system running on oracle db. Inside that I have a set of employees under different categories,sub categories etc.,. Now I have to build a system in drupal fetching these data+additionals. I planned to setup the category sub category etc, with the taxonomy and TAC in drupal. I have a set of SP for fetching data from oracle. My question is how can I relate the taxonomy terms with those category ids(Employees are classified under category ids, so I have to keep track of the taxonomy relates to the categories in oracle). I'm new to drupal. Please help me guys..
Perhaps you could add a field that stores the corresponding oracle id to the vocabulary in Drupal? That is if you cant name the terms directly so that they match the records in oracle.
I've used the following modules in the past to solve similar tasks. Perhaps they can be of use to you.
https://www.drupal.org/project/feeds
https://www.drupal.org/project/feeds_tamper
I stucked in a Problem When Playing with Drop Downs.I tried to use this
http://www.grocerycrud.com/forums/topic/1087-updated-24112012-dependent-dropdown-library/
But actually my requirement is quite different. I have a table fwld_products in which i am adding all other table's categories, from
fwld_cat_main (main Category's ID),
fwld_cat_sub1 (sub1 Category's id)
fwld_cat_sub2 (sub2 Category's id)
fwld_cat_sub3 (sub3 Category's id)
I want to Display Dropdown in such a way, when user Selects main
Category, the Drop Down Appear (sub1) Having Data related to main
category and when sub1 selected drop down appear (sub2) showing data
related to sub1, and sub2 selected and drop down appear(sub3) to show
data related to Drop down (sub2).
When submitted Finnally data inserted to [fwld_products].
Here I am attaching ERD, and result as well.
Please help
Hold on, it seems that DB structure of your categories table needs to be improved. What I suggest is that you follow footprints from some of the popular CMS like Opencart. It will give you a great sense to accomplish your task. You can easily optimize your DB by using just one "category" table (instead of main, sub1, sub2, and sub3 category tables) like this:
For category names, description, and meta keywords etc you can create this table "category_description":
Finally to assign categories to the products you can simply create another table "product_to_category":
In this way you can easily manage your data in DB and you can now easily tackle your situation using Codeigniter and Grocerycrud.
Try, Chained Selects Plugin for jQuery and Zepto (Github Project | Project Home)
If you use jquery or zepto in your project, this plugin will help you to solve your problem, Specially the remote version. You can create related select boxes easily.
Hope this helps :)
I am trying to create a database for storing cars information.
Cars can be categorized as new, used, or for rent.
Each type of car category has different attributes, because new cars have different features that are not needed for used, and same case for used and rent category. Attributes can be added, deleted in future using Application Admin side form manager for these 3 categories.
currently i am storing these in 1 product table with all the attributes required by these 3 categories.
PRODUCT(id,title,description,model,kilometer,enginsize,conditions,.....,.,...)
As form for each category is proposed to be managed from admin control, i am looking for a new scalable database.
current development:
all common attributes in Products
PRODUCT(pid,title,description,...)
CATEGORY(cid,cname) new,used,rent
form_field(formfield_id,name,type) to store all attributes that are not common
form_field_category(formfield_id,cid) to store category associated attributes
form_post_data(post_id,pid,formfield_id,value) to store submitted data
Any suggestions.
for what I understand you have 2 type of attributes: common and category-specific.
So doing something like:
PRODUCT(pid,title,description,...)
CATEGORY(cid,cname) new,used,rent
additional_info_category(aid, cid, name)
adition_info_data (adataid, aid, pid, data)
Should be enough, you just need to loead all the product info plus the fields in additional info that are related to the category.
You should have no issues adding new fields if they are category-specific but my question is: are you sure you won't need to add common fields?
What you need is called an Entity-Attribute-Value model.
If most of the values in table form_post_data are text, simply make it a varchar field. However if you're storing numeric values, choices and other types (things you might want to filter on), have a look at this article An alternative way of EAV modelling.
For you have properties that can have multiple values, have a look at this follow up article EAV multi-value fields.
I'm quite new to CakePHP so I'm wondering if anyone can help me with how to order my pages.
I have a table of products (with a Product model and products_controller).
I also have a table of categories (with a Category model and categories_controller).
The categories hasMany products.
Firstly, is the name categories incorrect to call it. According to CakePHP convention, what is the correct name to call it?
Secondly I would like the user to click on the products link and then be presented with a list of categories and finally, once he/she chooses a category be presented with the products in that category. How would this be laid out?
You're asking some pretty basic CakePHP stuff, I suggest you read the book, which outlines naming conventions, file structure and data retrieval to name a few things.
That being said, the name categories is correct, unless you want products to have more than one category, the relationship will be Product 'BelongsTo' Category.
To get category info inside the product controller you can just access it's find methods with $this->Product->Category->find();, but again I recommend you read through the CakePHP book as you go to build up our knowledge and learn more about the framework you're using.
You mean that categories is not a plural of category? I think so. Your table has to be named as 'categories'.
Secondly, I think that you need a Categories hasAndBelongsToMany Products (HABTM) in your model, so every Category has many Products, and also a Category belongs to many products.
Use the 'cake bake' command and you will see easily if it is what you want.
Hope it helped, althought I'm quite new in cakePHP as well...
Alf.
If you have categories tables in db, its controller would be categories_controller.php and the Products belongsTo Category will work if products belong to only one category. No need to HABTM relationship. See in cakephp the model files are in singular form and controller file are in plural form with controller attached with them. The tables are named in plural in db.
Regarding ur 2nd question, I think im not getting it exactly.