Creating a subscribe feature (linking multiple tables?)? - php

I currently have 3 sql tables "news" "content" and "users".
What I'm trying to achieve here is a subscribe/follow feature that allows users to follow anything listed inside the "content" table and then receive notifications whenever news is added regarding that content to the "news table". Will I need to link the 2 tables "content" and "news"in some way?. Other than I don't have any ideas at the moment. Any help will be really appreciated!

Use a TRIGGER on the news table. The trigger action will perform a JOIN to find the users who are following the related content.

Related

Is it good practice having separate database for different pages in a website?

I have a website xyz.com that is going to be launched in an online server. I have three pages x, y and z (suppose x is for image gallery, y is for video gallery, and z is for another gallery). I need to have a comment section for each of the pages, and user input is going to be stored in database. There need not be any relation between the comments in different pages, or in another words, comment from one page doesn't have to relate with the comments in another pages. I want to deal them separately.
Now my question is:
Should I use one database and create just three different tables for each pages or should I create three completely different database each of them having one table? Which one is good practice?
You do not need to create the different databases and why would you?
Create single database
Create 2 tables "galleries" and "comments"
galleries (id|title|name|type|date etc....)
Gallery type can be "image" or "video" or etc...
when you load data for image(s) page do
select * from galleries where type='image'
and when for video
select * from galleries where type='video'
so on...
For comments:
create table
comments (id|comment_text|gallery_type...)
where gallery_type is the foreign key
If your gallery types are lots you can always create a sperate table for gallery_types and give reference accordingly.
Use one database with as many tables as you need, there's no reason to create several databases for your project

can't select multiple contacts-One to many relate field Suite CRM

I have made one-to-many relationship between two modules Ads and Contacts..Made a custom relate field in Ads and placed it in edit view which opens sub panel of contacts.The reason is when creating an Ads user can select multiple contacts.But the issue is I can only select one contact from Ads create screen.How can i achieve this?or is their any other way to do this please guide i have searched a lot to do this but couldn't find anyway.
Current result:
I need it like this:
EmieOmdorff,Tom,Lacy

Save history products in Laravel

I want to write a method to save the history of changes in the table. I have three tables (products, articles and categories). When a user makes a change, for example in the product name. I want to display a message at the product, example: User Jack change the name of product with "ball" on the "ball2016."
I came up with that I created new pivot table "history_products" wherein the columns will: "user_id", "products_id", "created_at" and "updated_at". This table will be connected with table products. I want to used this trigger. You think it's a good idea or in a Laravel can do it in an easier way??
a good source/library is revisionable, the following:
VentureCraft/revisionable

How do i link database relationship with the following information?

I have been relentlessly trying to edit my database relationships but to no avail. Here is the scenario:
i have an inventory table. an inventory can be classified into 2 categories(technical eg. guns, radios and general eg. uniforms). i was hoping there could be a way for me to add details(from different tables eg. technical_inventory_table and general_inventory_table) to the inventory table through the category since the two categories have different fields. is there any way for me to do that? please do note that a technical inventory will be listed individually since a single item will have a serial number attached to it.
or does the answer provided here - https://dba.stackexchange.com/questions/33099/storing-different-products-and-joining-on-table-names - be an already good solution for my problem? i would like to avoid creating a table where it will be made up of what usually are the fieldnames as described in the link to prevent confusion within my team.
thanks for any help in advance

User Reviews: Implementation of Comments - What technologies to use?

I have set up a company intranet website built with PHP/MySQL and allow users to post reviews. After joining up on this website I have grown to like the "comment" function and would like to add that same functionality to allow users to "comment" directly to other users reviews.
Currently all reviews are stored in a single table in the DB.
1) Should I create another table to then store all the comments since there can be many comments per review?
2) Once I figure out where to store these values can the rest of this functionality be built out in PHP or will other programming need to also be introduced?
Sounds like a good plan. You can have a table like Comments(commentID, reviewID, comment_body, ...). You can then insert a new entry when adding a new comment, or select all comments with a given reviewID to display comments for a given review.
Yes, you will almost certainly implement this in PHP (the same language you use in the rest of your application). You'll also have to edit some HTML, and maybe javascript as well.
Yes and yes.
Comments should be a seperate table, because they're comments, not reviews. They are two different things, therefore, they should not go in the same table.
Once you've created that table with the appropriate references to other tables, it's just a matter of constructing a query which pulls out all of the information you need (e.g. SELECT user.user_name, comment.comment_text, comment.post_time FROM comment, user WHERE comment.user_id=user.user_id AND comment.review_id = 123, where 123 is the ID of the review you're getting comments for).
The exact layout for your comment table will depend on your specific needs, but as a minimum, you'll want to know which review it's a comment for, who posted it, when they posted it, and what they actually posted.
To insert comments, create a form on the page that displays the individual review, and when filled in, create an INSERT query which inserts into your comment table.

Categories