Jump to content

jimfog

Members
  • Posts

    1,803
  • Joined

  • Last visited

Posts posted by jimfog

  1. Would it not be better in not having two tables store more or less the same data, but have single table and have a field to identify him as regular or business user instead. Then you just change that field from one or the other.

     

    What type of column would be that the will identify a user from being a regular or business user? I do no think it should be enum though because we are talking here only about two possible values

     

    Use a table as base 'regular user' table and use another table for business user where there will be a foreign key pointing to regular user. If a use chooses to close his business identity just let them delete the data from business user table, whereas there will be still data for him as regular user in corresponding table. You should avoid duplicate data where possible and use reference instead.

    Are you saying that this "regular users" table will hold data common for the 2 types of users and the business users table will hold only data relevant to the

    business user?

  2. There is one more thing that I want to ask and has to do with the logic describe above.

     

    Do you think there are any problems by have a 2 cols table which are both foreign keys pointing to a col in another table?

    Suppose there are not any problems from it. Do you think is redundant?

     

    Here is an image that visualizes the relationship:

    http://sdrv.ms/1fkMlbJ

  3. you were right, I was not so specific. This app has 2 types of users, regular and business, with their credentials(Id,email,password) held in the credentials table.

    The rest of the details of these type of users, are held in 2 different tables, regular_users and business_users

     

    Both type of users when using the site have the option of keeping favorites, the favorite item here is business user.

    Meaning a regular user and a business user might have as a favorite another business user.

     

    So my question revolves around the structure of a favorites table. So far, I have concluded to one-to-many relationship(FORGET WHAT I AM SAYING TO THE FIRST LINES ON THE POST ABOVE AND CONCENTRATE ON WHAT I AM SAYING NOW).

     

    The favorites table will comprise of 2 columns, the one being a foreign key referencing to the credentials table and the second column(which will hold the favorites items) a foreign key also referencing again the credentials table.The reason that both columns reference the credentials table is that by definition the users that keep favorites and the favorites(being other users---business users) are located all in the credentials table.

     

    How does the above structure sounds?Do you think there is a "hole" in the logic.

    Do you want me to add more details?

  4. I am constructing a table where it holds a many to many relationship with other 2 tables.

    This many-to-many table has 2 columns, both of which are foreign keys to 2 other tables.

     

    The many-to-many table is called favorites(it is self-explanatory what it does) and the parent tables are called business users and credentials.Here is an image:

    https://skydrive.live.com/redir?resid=BE27434B2AAC8130!259&authkey=!ADptTU72dh1KYBc&v=3

     

    As I understand, and tell me if I am wrong, none of these 2 columns must be primary key.

    The reason being that a primary key must be unique in every row, but in a many -to-many table many times values are repeated throughout rows.

     

    For example, many orders placed by the same customer(not related with my app).

     

    So, am I right saying that none of the columns must be a primary key?

     

    In addition, now that I am reconsidering things, maybe a many to many table is not needed, just one-to-many, from credentials to favorites.

    Since the credentials table holds all the id's of the users of the site.

  5. So...the bottom line is that having two tables(regular users and business users) that have same attributes(name and last name) is wrong.

     

    Anyway I am going to redesign the table some moment in the future.

    For now, and in order to deal with the issue mentioned in the beginning of the topic I just foreign_key_checks to 0, so that the query can be performed.

     

    it is just a temporary solution.

  6. I finally concluded in the following logic which cannot be implemented though due to foreign key constraint issue.

    Here is what I am trying to achieve:

     

    1.First "take" from the business users table the crID(primary key)m, the name and last name.

    2.Delete the b.user account.

    3.Transfer the data from the first step to the regular users table

     

    The problem is that the above violates a foreign key constraint, a foreign key which goes from the credentials table(parent table, it holds the username and password and crID which is the primary key) to the regular users table(child table which holds name and lastname)

     

    What can I do?

  7. so you are saying that in the regular users table there will ALSO be the name and last name of the business users.

     

    Currently the name and last name of the business users is contained in the business users table.

     

    I think what you suggest messes things a little.

  8. I have 3 tables...one that holds credentials of the users(password, email etc).

     

    A 2nd table where the name, lastname of the regular_users are kept and 3rd table where the name,lastname of the business users are kept.

     

    I want to do this:

     

    Suppose the business user chooses to close his account as a business user but retain him only as a regular user.

     

    Is is possible to transfer the name,lastname to the regular user table and associate these with credentials already found in the credentials table?

  9. as you said it works without it also.

     

    So what is the point using it? From your answer I understand(and tell me if I am wrong) that it is needed for cross browser

     

    compatibility. Meaning, without it, some browsers may not interpret correctly an event.

     

    In my code, so far, I have never used it...

  10. Recently I came across with a code like this:

    $('#button').click(function(e) {        // Button which will activate our modal            $('#modal').reveal({                // The item which will be opened with reveal                animation: 'fade',              // fade, fadeAndPop, none                animationspeed: 600,            // how fast animtions are                closeonbackgroundclick: true,   // if you click background will modal close?                dismissmodalclass: 'close'      // the class of a button or element that will close an open modal            });

    why the function has as a parameter the letter e?

    The code is found here:http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/build-a-popup-modal-window-using-the-jquery-reveal-plugin/?search_index=2

     

    Scroll down to step 8. The article refers to the jquery reveal plugin.

  11. It is not clear to me what you are wanting this code to do. I would think that you would want the top button to toggle the visibility of the lower portion?

    In fiddle you will see that in both fieldsets 2 inputs are contained where they are set to read only.

     

    Is there a way using the filter() method so that only one input element from that two is set to read only.

    The js code you see in fiddle targets all input elements within fieldsets.

     

    The code you see is a piece from the code I have locally. The whole code has more fieldsets-that is why

    I want to use filter, unless of course there is a better way to achieve what I want.

  12. I have 2 fieldsets where they contain one input element each and with js I have set these to read only.

     

    Here is the code:

    http://jsfiddle.net/fiddlehunt/WJ8qU/20/

     

     

    I have 2 questions.

    1.WHy the hide class is not applied to the fieldsets as set by the js code and

     

    2.How I can use the filter(if this is the correct way to do it) method so that the js code does not apply in a specific element?

    Meaning that the input element in one of the fieldsets can be written wile now both input elements in both fieldsets are set to read only.

  13. That's a question for you to answer, you know your application. If you want to delete the user permanently and you store references to them in multiple tables, then make sure you remove all of the information. Or maybe you want the other information to stay there and just not be linked to any user account. Or maybe you want to move them to a deleted users table so that you can restore a deleted user. It's up to you, it's your application, you know how it works.

    Yes you are right but I was not referring so much in the db part but in the session and redirection part

  14.  

    So with account deletion you delete their record from the user table and then kill their session and direct them to the front page?

    That what is I am considering, but I am not sure if it is the proper course of action or I must add something else to.

  15. How do you currently log them out?

    I unset the session and redirect them to the frontpage-all done with server side code.

    But someone when logs out is different than account deletion,,,in the first case we do not have account deletion.

     

    Are you suggesting anything?

  16. ok...I have more 2 questions regarding the deletion of a user's account.

     

    Is it OK to use ajax-anything wrong with that?

    When an account is deleted what other actions must be done also(session, cookies etc)?

  17. For triggers, you can use the SHOW TRIGGERS query to show all of the triggers. For foreign key constraints, choose a table and select and Relation View.

    From the above mentioned nothing achieves what I want...instead the solution is this.

    DELETE ON CASCADE.

  18. I tried to git init but I could not. I mean in the git bash I do see the init taking place but(with the dir listed and the word master in brackets in the right )

    in the folder where I should find the .git folder I do not.

     

    What might be wrong?

    Ah...now I see it. It was hidden.

  19. I tried to git init but I could not. I mean in the git bash I do see the init taking place but(with the dir listed and the word master in brackets in the right )

    in the folder where I should find the .git folder I do not.

     

    What might be wrong?

  20. I want to delete 2 rows(one row in each table)-these tables are innoDB both were one column in one table references the column in the second table.

     

    I know that by deleting the column in the parent table the corresponding column in the child table also gets deleted.

    I assume that the delete statement will only mention the parent table-like I am deleting the row in one table and the deletion in the child table will be taken care of the storage engine.

     

    But how am I going to be sure that this the case.

    I have PHPMyAdmin and workbench-from where I will see that indeed this is the case?

     

     

×
×
  • Create New...