Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    MySQL relations database

    Hello,

    i got a project right now with php/mysql in school and i need some help with this.

    I need to make a MySQL database with atleast 3 tables that are related with relations. The problem are i have never done this before so i don't really know how to use relations databases and why you should use them.

    My project are a simple news site with for the moment 2 tables only News and Users. So i need an idea witch tables i could have in a news site that could be relations and how :P.

    Thanks in advanced if someone could help me with this!

  • #2
    New Coder
    Join Date
    Jan 2014
    Location
    coimbatore tamilnadu
    Posts
    12
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Thumbs up i am new coder relatioanal database

    just simply write tables all tables in a database then u will hav a unique id for all users right call with it still face some prob post and get ideas do one by one
    pls share with me too


    thats it that much i know

  • #3
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,415
    Thanks
    269
    Thanked 32 Times in 31 Posts
    This tells me that your instructor/teacher is worthless. Just ask him for some extra help becuase you are not understanding the concept. That is his job...

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,720
    Thanks
    80
    Thanked 4,514 Times in 4,478 Posts
    Code:
    CREATE TABLE news (
       newsid INT AUTO_INCREMENT PRIMARY KEY,
       newsArticle TEXT,
       whenPublished DATETIME
    ) ENGINE INNODB;
    
    CREATE TABLE users (
        userid INT AUTO_INCREMENT PRIMARY KEY,
        username VARCHAR(30),
        password VARCHAR(20)
    ) ENGINE INNODB;
    
    CREATE TABLE news_read_by_users (
        userid INT,
        newsid INT,
        whenRead DATETIME,
        CONSTRAINT FOREIGN KEY (userid) REFERENCES users(userid),
        CONSTRAINT FOREIGN KEY (newsid) REFERENCES news(newsid)
    ) ENGINE INNODB;
    Now it is your turn.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •