Welcome Guest, Not a member yet? Register   Sign In
How to get database schema.
#11

[eluser]Colin Williams[/eluser]
Quote:Can you please tell me how you are create that both create.mysql and insert.mysql from code

I'm going to go out on a limb and guess he used some function calls, some SQL queries, some logical structures, maybe some loops. Definitely variables.

In the two days that this thread has been open, how is your code shaping up? Maybe you can share it with us and we can lead you down the right paths.
#12

[eluser]vikas khairnar[/eluser]
How can use "SHOW CREATE TABLE “tablename” this query to take structure of specific table while I have an array of tables whose structure is need to be stored in specific file.
#13

[eluser]jedd[/eluser]
As it happens, I create these manually at the start of the project, and maintain them during development. They're just text files.

If you've already created a database using some tool that doesn't provide you the ability to re-create it, then I'd suggest you've chosen your tool poorly.

For many people it must seem weird to use a text file to generate a database - given GUI's are so much slower and involve more hand movements and don't let you plug into your code versioning software too easily and generally give you less control over what you're doing (the Microsoft Effect, if you will).

As pointless as this will likely be, here's my CREATE_member.mysql file:
Code:
CREATE TABLE member (                            # the USER table, by any other name.
    id                     INT UNSIGNED NOT NULL AUTO_INCREMENT,
    appellation            BIGINT,                    # FK to appellation table (later)
    handle                 CHAR(50) UNIQUE,
    first_name             CHAR(50),
    surname                CHAR(50),
    email                  CHAR(70),                # email address
    website                CHAR(70),                # @TODO - should they get just the one?
                                                # - possibly utilise the separate URL column?
    password               CHAR(32),                # MD5, of course
    last_login             DATETIME,
    last_ip                CHAR(15),                # last connected IP address, in numerical form
    created                DATETIME,
    timezone               INT,                    # FK (timezone.id)
    country                INT,                    # FK (country.id)
    theme                  INT,                    # FK (theme.id)
    referrer               INT NOT NULL,            # FK (member.id) - the person who referred this person
    admin                  BOOLEAN DEFAULT FALSE,    # LATER - work out a better ACL / Permission system

    flag_locked            BOOLEAN DEFAULT FALSE,    # User account suspended?  (@TODO - where to track who did, and reason for ~)

    pref_ipp               SMALLINT DEFAULT 10,    # PREF - Items Per Page (used for all pagination)
    pref_email_private     BOOLEAN DEFAULT TRUE,    # PREF - Notify by email on private message
    pref_email_public      BOOLEAN DEFAULT FALSE,    # PREF - Notify by email on forum/public message

    sv_messages_posted     MEDIUMINT DEFAULT 0,    # summary value - total number of messages posted (updated when posting)
                                                # (tear to the eye stuff, as this is my first intentional de-normalisation)

    INDEX (handle),
    PRIMARY KEY (id)
    );

And an excerpt from my INSERT_member.mysql file. No tittering, please.
Code:
INSERT INTO
    member  (handle, appellation, first_name, surname, password, created, theme, referrer, admin, country)
    VALUES (
        "admin",
        (SELECT id FROM appellation  WHERE text="Prince Regent"),
        "Administrator",
        "Administrator",
        MD5("secret"),
        now(),
        (SELECT id FROM theme WHERE name="blue"),
        1,
        1,
        (SELECT id FROM country WHERE name="Australia")
        );

As alluded, if someone can come up with a better (faster, clearer, more robust, even more compatible with SVC) method of maintaining and tracking the schema and test data, I'd love to hear about it.
#14

[eluser]vikas khairnar[/eluser]
But I want to do this using code how it is to be done?
#15

[eluser]jedd[/eluser]
[quote author="vikas khairnar" date="1258741354"]But I want to do this using code how it is to be done?[/quote]

My method uses code. I'm not sure what else you're seeking here.

It sounds like you're stuck in a place that you got to by your choice of GUI tools to create a database schema, and now you want to extract textual information back out of that. Is that right?

It's a) not a CodeIgniter issue, b) self-induced, c) a problem that's solvable by the information already provided.




Theme © iAndrew 2016 - Forum software by © MyBB