I'm having a hard time to create a schema for my CMS. It is a reservation system for hotels/resorts. I have two users and two connected websites, one for the client and the other for hotel/resort owners (CMS). The owners should create his own account and using that account he can add more than one hotels/resorts, the problem is the owner should be able to add an admin or another user that can access his account so that in case he would not be able to update his reservations he can ask his assistant to update the it. My current schema is like this
Users
id
name
bday
age
and other personal details
then..
Hotels
id
user_id
name
rooms
and other details
When the owner logged in to his account Im getting all his hotels using this query:
SELECT * FROM hotels WHERE user_id = <owner id>
Im thinking of just adding another column like (user_id_2) and (user_id_3) in hotels table. but i don't think that's the right way because that would limit the number of admins. What do you guys think?
Related
I would like to create project and following is scenario :
Database tables:
Table first : Company
Table Second :Employee
when superuser create company then i put information in company table like company name, user name and password.
Then with these username and password company login and enter its employee like name, gender , phone no etc plus username and password for employee so that employee can login as well with its employee rights.
confusion is that when superadmin create new company then it enter values in company table and when company create emplyee account then i enter value in employee table. So on login screen how i can check its superadmin, company or employee so that i can get information from that perticular database table.
Can you guys help me to create database for this scenario. how i can manage what should i use join , view or.....
thanks
Your database structure is correct as you're putting relevant information in each table. E.g. Company's data in company table and Employee's data in employee table.
What you need to do is when someone logins from platform add a extra parameter along with credentials for the type of user.
There are couple of solutions for this,
Create two separate pages for Employee and Company's login.
Have single login page for both of the user having selection box for the user type.
In my simple system there is a users table where user logins and passwords are stored as well as a customers table.
Users can be related to customers in 3 different ways.
1) Sales Representative to the customer
2) Lead generated by this customer
3) Customer account entered by this rep
Originally I planned on having all on the customers table:
customers.user_id customers.lead_id customers.entered_by_id.
With CakePHP is this the wrong way? How should it be designed?
I am 1 day new to CakePHP.
Without knowing more about what you are building and your requirements, this is what I would do:
users: contains just authentication info
users.role: useful for querying what role a specific user is (customer, sales rep, admin, etc.)
users.username
users.password
sales_representatives: contains sales rep data
sales_representatives.user_id: Links the sales rep data to a specific user
customers: contains customer data
customers.user_id: Links the user to a specific user (assuming you want them to log in, if not you can skip this)
customers.sales_representative_id: Links a customer to a sales rep. You might want to store a history of sales reps for a specific customer in a separate table, but this field is just the current sales rep.
customers.lead_id: Links to a specific lead this customer came from. Can be null in case it was inbound and not a lead, but will probably link to something useful.
leads: Contains lead data
leads.sales_representative_id: Contains the current sales rep for a given lead. As with the customers table, you might want to store a list of historical sales reps for a given lead in a separate table.
You might also optionally add a user_id to the lead table if a lead can login, but that might not be the case in your system.
What is your entered_by_id? That seems more like a lead-related id, in which case you may want to track that in the leads table (separate from the sales_representative_id).
Most of this stuff isn't CakePHP-related, though good schema planning will go a long way to making using CakePHP easy :)
I'm looking for guidance on the database structure for a multi-regional website.
I am setting up a website, similar to craigslist.com, that will allow users to post adds in their city. I am using a MySQL database.
I want to have regions as subfolders linked to subdomains e.g. ca.mysite.com goes to mysite.com/ca.
My question is how do I manage the database(s) when I want to add another city to my website.
If I use a different database for each city, then users wont be able to login to other cities as their login details are stored in the city they registered at in the users table of it's db.
This may not be an issue though, as the content is city specific, like craigslist.
But, should they wish to contact users in other cities, they wont be able to.
Also, there would be duplicate username's and email addresses overall, as users could register in all of the cities using the same email and username.
If I create a central database with for instance, a users table, and a messages table, and then a separate db for each city with all that cities 'posts' then when displaying basic information I will need to consult the city specific db plus the central db that stores user info.
Alternatively I could store everything on one database, and store the logged-in user's location in a cookie, pass that to a session variable, and use that location as part of the database query when displaying search results etc.
However, would this not add an unnecessary overhead to each query?
e.g. every search would have to have ' AND location = $user_location ' added in.
I really have no idea what would be the best method here.
Thanks in advance for any help on this.
It seems that you still do not know clearly the system you want to build. Before starting designing a database for this system, please make sure that you have the full description of the system requirements. Some sample questions that help you clarify are:
What features does your website offer?
What are all the actions that a user using your system can do? With each action, is there any restrictions?
Some other questions relating to the system performance:
- How many users do you expect to use your system?
- How fast and correct each action should be served? Which actions are used frequently?
It makes no sense to design a system without a careful understanding about the system requirements.
So here is the sample database design and how it can support your requirements.
Cities(cityid, cname)
Users(userid, fname, lname, cityid, currcityid)
Messages(mid, senderid, receiverid, content)
Adverts(aid, title, content, userid, cityid)
When a user switches the city, update the currcityid field in its row in the Users table.
When a user posts an ad on a city, insert a new row to the Adverts table. The userid and cityid of the new row are the ids of the corresponding user and city.
When a user sends a message to another user in the system, add a row to the Messages table. The senderid and the receiverid of the new row are the ids of the corresponding users.
Query all ads in a city: SELECT * FROM Adverts WHERE cityid = $cityid
Query all ads of a user: SELECT * FROM Adverts WHERE userid = $userid
Query all ads of a user in a specific city: SELECT * FROM Adverts WHERE cityid = $cityid AND userid = $userid
Hope this helps.
okay so I'm developing this website for my capstone class, it's a ticket reservation system. I'm using phpmyadmin on wamp server. My question is, at any point of time many users will be on my website.
They register or login, and according to their status ( being a Director or Audience) they can reserve a number of seats. So suppose if 2 users are on my website, one as a director and the other as an audience. How can I know which user is which?
When they register, the status is stored in the database, but how can I know which user has which status that are both on my website?
Thanks
From my assumption if both User has different user name and password from these information you can find login user status.
I will suggest to create a mapping table of Roles with User.
For example, User, Role and UserRoleMapping Model.
User ( id, username, FirstName )
Role ( id, role )
UserRoleMapping ( user_id, role_id, status )
Here when User makes an registeration, then as per its role create an entry in UserRoleMapping Table.
Then use of the view to display the list of UserRoleMapping, use their id to display their name and role. Make use of filter in tabs for different role by ordering with respect to created datetime.
To make more advance, you can also display the number of success login, login failure, latest login etc.
I'm going to allow companies to register on my website and create job listings.
I'm currently approaching the problem by creating a Company table with Name, Logo and Password fields. Then when a person registers he can say, "I belong to X company"; at this point, I'll request the password written in by the initial registrator. If she/he enters the correct password then he is given permission to create job postings in the name of the company.
Why I'm doing things this way:
If I just put everything inside of the Company table, every new user would have to create an account and I'll have redundant information, CompanyName, Logo, etc.
And if I do things without a password, anyone can post a job opening under a companies name and that's just wrong.
Care to share some input? Am I doing things wrong? How would you do it?
I would do "jobs requests" like Facebook's friend requests and if the user really work in that company, the company manager just has to login and confirm it.
Database Normalization.
Create a separate Users and Companies table. Can one user post for multiple companies? if so, you need a many-to-many relationship (which requires a third table to keep track of the relationships). Otherwise, a one-to-many should work.
You should create two tables:
Company:
- id
- logo
( - name, etc )
User
- id
- companyId (foreign key to Company.id )
- password
( - username, etc. )
This way a User is a child of a Company identified by companyId. Now, if a user logs in, you can identify what company s/he belongs to by finding the Company corresponding with the companyId. Now you have a password per user, and a company per user.
And like Jimmy says, if you need Users to be able to be part of more Company's you would get:
Company
- id
- logo
User
- id
- password
Company_User
- companyId (foreign key to Company.id )
- userId (foreign key to User.id )
in my opinion you should create table like
Employers:
eid(pk)
logo
Username
Password
profile
etc....
JobSeekers:
jid(pk)
Username
Password
etc...
JobPosts:
id(pk)
eid(Fk to Employers.eid)
JobTitle
Specifications....