Create several group based on their Interest-based [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Create several group based on their Interest-based. I am using php and mysql.
my user table
name_one
name_two
name_three
name_four
etc..
6.
7.
8.
I would to select some names and create a group
Ex:
256 users interest in football = Foot Ball group
549 users interest in cricket = Cricket Group
Note: Football users can be in cricket as well.
My question is how can I create many users group from user table rows. Should it create extra table? Please help me.

I suggest you to create a table interest(id_interest, name), then a 3rd table interest_user(id_user, id_interest)
I suggest using interest as table name instead of group because it has a special meaning in mysql.

Related

What SQL query should I use to output the value of my 2 tables? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I am a student and is new to MySQL
I have 2 tables, ors_uniform contains 7 products that has 9 sizes (XS-5XL).
ors_prices contains the fk of table1 and the prices per size (9 sizes)
I wanted it so that when I output the inventory of the products, the price will be shown next to it. I know how to do that using php already but I don't know what MySQL query to use.
I currently just use SELECT * FROM ors_uniform
2 tables
let's assume the fk is a foreign key and it is available in both tables.
select * from ors_uniform join ors_prices on ors_uniform.fk = ors_prices.fk;

Vote any one team through application and one user can vote only single time in a day [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
There is an application regarding Cricket Tournament there are few teams in that tournament . we can vote any one team through application and one user can vote only single time in a day How can be possible ,just share logic and thoughts.
U can do it with db.
In the DB u should create a table with columns like-
votes(
user_id,
team_id,
date,
......,
unique (user_id, team_id, date)
)
Then if a user gives vote, u should store votes here.
Look carefully there is a unique field in the database on user_id, team_id and date.
SO only one vote for one team by a user in a day can be possible.
Before storing a vote, u should check if there is a vote for the team by he user in that day already.
If yes, then u should not store the vote.
If no, then u should store the vote.
It will work for u.

Mysql table design and implementation [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I have this table that i want to create in my database:
ID--Name--Major1--Univ1--Major2--Univ2--Major3-Univ3
The problem is, maybe the user did 9 majors. What i'm going to do create a table of 18 columns of major and univ... So is there a dynamic technique followed for this type of situations?
Make 3 tables
Primary tables
Universities
id | name
Majors
id | name
students
id | name
bridge_table
student_major
students_id|university_id|major_id
You use two tables. :)
One table is the student table.
One table is the university / major table with a link to the student_id from the other table. Then a student can get unlimited majors. ;)

Dynamic data matching between users based on user selection [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm hoping one of you more experienced programmers might be able to shed some light on this situation:
My site allows users to create a profile and enter in their favorite musicians, all of which reside in a pre-existing database of musicians.
Based on the artists they select, I want to display to them other users who have selected the same artists.
Can anyone offer suggestions on how this could be effectively accomplished?
I'm using SQL and PHP for the back end.
You would need to create a cross-reference table between users and musicians that defines the 'likes' relationship. At a minimum it would just need to contain the user id and musician id.
CREATE TABLE user_likes_musician (
user_id INT NOT NULL,
musician_id INT NOT NULL,
PRIMARY KEY(user_id, musician_id)
);
To find users who liked a particular musician you can just join the likes table with the users table:
SELECT * FROM users
JOIN user_likes_musician
ON (users.ID = user_likes_musician.user_id
AND user_likes_musician.user_id <> [current user id]
AND user_likes_musician.musician_id = [musicians id]);

How to make for each user, documents start by id 1? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I need to make database for users and every user have documents which will line up in this order for
user1(document1 have id 1, documnet2 have id 2, documnet3 have id 3, etc...)
user2(document1 have id 1, documnet2 have id 2, documnet3 have id 3, etc...)
?
Create two tables to accomplish this.
The first table should contain your users. Example:
|id|username|password|
|1|user1|1234|
|2|user2|1234|
Then create a second table containing your documents
|id|document|owner_id|document_id|
|1|adocument.doc|1|1|
|2|anotherdoc.doc|1|2|
|3|adocument.doc|2|1|
|4|anotherdoc.dco|2|2|
In this example you see that the documents in the document-table point to a owner_id. This should be the id of the user in the users table.
This is just to head you in a direction for a solution to your question. We cant write the entire code for you, so start googling a bit on mysql.

Categories