Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing MYSQL entries - would be helpful #3

Open
computeruteach opened this issue Jan 13, 2024 · 2 comments
Open

Missing MYSQL entries - would be helpful #3

computeruteach opened this issue Jan 13, 2024 · 2 comments

Comments

@computeruteach
Copy link

I created a table called users with username and password and that was as far as I got. Can you please let me know what the tables are in MYSQL? Are they only for the login.php and signup.php?

@mishrakajal2200
Copy link

Creating a table named "users" with columns for username and password is a common practice when dealing with user authentication in MySQL databases. However, the structure of your database can expand beyond just a single table for user credentials.
Here's a basic example of tables you might have in a simple authentication system:

Users Table:
Stores user information such as username, password, and possibly other details.
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
email VARCHAR(255),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Sessions Table:
If you want to implement session management, you might have a table to store active user sessions.
CREATE TABLE sessions (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT,
session_token VARCHAR(255),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);

Roles Table:
If you want to implement user roles (e.g., admin, regular user), you could have a table for roles.
CREATE TABLE roles (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50) NOT NULL
);

UserRoles Table:
A junction table to associate users with roles in a many-to-many relationship.
CREATE TABLE user_roles (
user_id INT,
role_id INT,
PRIMARY KEY (user_id, role_id),
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (role_id) REFERENCES roles(id) ON DELETE CASCADE
);

@computeruteach
Copy link
Author

computeruteach commented Jan 26, 2024

Ok it's working, however there is no products. I am guessing I need to at least make a MYSQL table: "tblproduct" and "id" with "name" "$" and "price" ? I have found these references in products.php.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants